I have noticed that alot of sites pass there ID variable threw the url to the next page. does anybody know how to do this so when u click on the ID link it opens a new page with the same variables on it? an example is like this (http://www.bahb.net/index.php?file=648) any help here would be nice, im just trying to make a simple game site.
I think this would be the right way to go: http://www.bahb.net/index.php?file=<?php echo $_GET['file']; ?> Code (markup):
$url = $_SERVER['PHP_SELF'].'?'; foreach($_GET as $is => $what){ $url .= "$is=$what&"; } echo 'http://'.$_SERVER['SERVER_NAME'].'/'.$url; PHP:
I came across this topic as I was searching for a way to encode the variables I send in an URL. noppid, can you give me an example on how to use urlencode? Cheers
It's pretty straight forward, check out the PHP.net explanation (they do a more in depth than I ever would) us3.php.net/urlencode urlencode() us3.php.net/manual/en/function.urldecode.php urldecode()
I don't know what's wrong, it just doesn't encode the variables I'm trying to send out. I have something like this: file.php?var1=256MB&var2=100. I tried creating the link like in php.net: <?php $query_string = 'var1=' . urlencode(256MB) . '&var2=' . urlencode(100); echo '<a href="file.php?' . htmlentities($query_string) . '">'; ?> Code (markup): This just makes my url look like I'm not using encription. Any thoughts on how to encript my urls?
urlencode isn't actually for the encoding of string, it's more of a url formatter, it replaces spaces with %20 and such, no encoding as you know it goes on at all, just some preg_replacing, and so in the above example, urlencode isn't performing any actions at all as the words (256MB & 100) are acceptable format to be in a url. What exactly is it you want the link to appear as and where is it gettin vars (256MB & 100) from ?
I want the regular user not to be able to modify the variables I send via URL. The page from which the variables are sent is here. I then need to use the variables in several places on the destination page.
simple way to achieve that would be base64_encode(urlencode($var)) and on the destination page, do base64_decode(urldecode($var)) on all vars in every url maybe someone else has a better idea..... If it's for a search page, you could use search ids, but inserting the form data into a `sids` table an storing what was searched in there, you could also add the search ids to session and display recent searches, or set cookies for search ids ....
I did this: <a href="mp3-player-CX112.php?cap=<?php base64_encode(urlencode('256MB'))?>&pr=<?php base64_encode(urlencode('116'))?>">Mp3 Player CX112 256MB</a> Code (markup): It doesn't seem to work. Any other ideas?
I could come up with some ideas if I knew more, for instance, I don't get why you want to encode the urls if they are clicked on a page that clearly states what the url is for, seconds I don't see why you would want a static list of urls in the first place ?