Fwd: [PHP] Updating a GET variable
| From: | Tamara Temple | Date: | Wed, 10 Nov 2010 06:50:19 +0000 |
| Subject: | Fwd: [PHP] Updating a GET variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309423@lists.php.net to get a copy of this message | ||
Begin forwarded message:
From: Tamara Temple <tamouse.lists@gmail.com> Date: November 10, 2010 12:05:32 AM CST To: PHP General <php-general@lists.php.net> Subject: Re: [PHP] Updating a GET variable On Nov 9, 2010, at 2:47 PM, Marc Guay wrote:Woops, just realized a problem with this. If the values in $_GET are URL encode, http_build_query will encode them again, so you have to decode them first: foreach($_GET as $k => $v) $qs[$k] = URLDecode($v); $qs['lang'] = 'en'; echo '<a href="index.php?'.http_build_query($qa).'">Flip</a>';I would add the parameter you want to $_GET ($_GET['lang']='en') and use http_build_query on $_GET if you really want to include the whole query string in the call: $_GET['lang']='en'; echo '<a href="index.php?'.http_build_query($_GET).'">Flip</a>"What's wrong with just putting the url parameters in the link that you know you need, one by one?I have a footer that I include on every page and would like it to adapt to whatever situation it finds itself in. Is your suggestion, to do the following for the existing example: echo "<a href='index.php?name=".$_GET['name']."&this=".$_GET['this']."&lang=en'>Flip</a>";Also, don't just output the values sent to the server, as that's an attack waiting to happen.Are you referring to echoing the SCRIPT_NAME and QUERY STRING values into the href attribute?