PDA

View Full Version : Error with redirect + variables


nirv
Tue 28th Dec '04, 8:10am
I'm using the hidden login forum field to redirect after login.

This is the code:

<input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="url" value="http://mysite.com<? echo $gk_url; ?>" />


$gk_url is the variable that contains the url...for example: /page.php?var1=var1&var2=var2
The problem is that when the page is being redirected the variables tree are being chopped off, or rather this url: /page.php?var1=var1&var2=var2 is converted to: /page.php?var1=var1

merk
Tue 28th Dec '04, 9:42am
Try using $_SERVER['REQUEST_URI'] instead.

Or, running either of the variables through htmlspecialchars() like function. (im not sure if the one im used to is vbulletin specific or not, but youll be able to find more info on the php website)

nirv
Tue 28th Dec '04, 10:04am
I've found a solution for this problem.
I have had to rebuild the url getting the vars with $_GET

The url is: authenticate.php?gk_url=/whitalia/sezioni.php?id_sn=1&id_sez=9&

Instead of using this code:

<input type="hidden" name="url" value="http://www.mysite.com<? echo $gk_url; ?>" />

..i've used this:

$array_vars = $_GET;
echo "<input type=\"hidden\" name=\"url\" value=\http://www.mysite.com (http://www.mysite.com/);
$i=0;
while(list($key,$value) = each($array_vars))
{
if ($i==0)
{
echo "$value&";
} else {
echo "$key=$value&";
}
$i++;
}
echo "\" />";