URL encoding decoding or nothing at all
Posted: Thu Jun 26, 2003 12:06 pm
Ok guyz I have good one for you! see if you can figure this one out
I have a select box e.g.
The while loop assigns values in select menu...
Now I am using GET form method to post the form values to another page, the VALUE in select menu is URL strings, e.g. $id&name=$name constructs the URL to what I want i.e. http://www.whatever.com/process.php?sel ... gy&what=no
which when posted gets encoded and changes to http://www.whatever.com/process.php?sel ... 2what%3Dno
NOW on process.php (the target page) i tried to be smart and used urldecode() to decoded the URL, back to the way it should be! like this>>
$url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
$url = urldecode($url);
Now the question is how do I extract the URL parameters which I use to get easily with $HTTP_GET_VARS[], but now I have the URL in $url,
OR
how to keep from URL getting encoded in first place?
As for why do I have to post all these values via select menu! well all I can say is... I just have to!
I have a select box e.g.
Code: Select all
<form name='test' method=GET action='process.php'>
....// some query... get records start while loop
$varfromphpscript = '$id&name=$name&whatever=$what';
while loop begins { ?>
<select name="select">
<option value='<?php echo $varfromphpscript; ?>'><?php echo $varnamefromphpscript ?></option>
.....
</select>
<?php } //while loop ends ?>
</form>Now I am using GET form method to post the form values to another page, the VALUE in select menu is URL strings, e.g. $id&name=$name constructs the URL to what I want i.e. http://www.whatever.com/process.php?sel ... gy&what=no
which when posted gets encoded and changes to http://www.whatever.com/process.php?sel ... 2what%3Dno
NOW on process.php (the target page) i tried to be smart and used urldecode() to decoded the URL, back to the way it should be! like this>>
$url = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
$url = urldecode($url);
Now the question is how do I extract the URL parameters which I use to get easily with $HTTP_GET_VARS[], but now I have the URL in $url,
OR
how to keep from URL getting encoded in first place?
As for why do I have to post all these values via select menu! well all I can say is... I just have to!