...

View Full Version : redirect with variable



ptmi
04-29-2006, 05:01 PM
How can I redirect with variables

I renamed page.php?id=1a2b3c to newpage.php?id=1a2b3c

The 1a2b3c is a variable and changing.

Thanks for any help

chud_wallice
04-29-2006, 05:25 PM
does this help?

http://uk.php.net/manual/en/function.urlencode.php

ptmi
04-29-2006, 06:42 PM
Thanks but I couldnt make anything from that page.

mobilehell
04-29-2006, 07:10 PM
not sure what you want but if you want to send users from page.php?id=1a2b3c to newpage.php?id=1a2b3c then maybe this might work if you paste this in page.php


$yourid=$_GET["id"];
echo "<meta http-equiv=\"Refresh\" content=\"0;url=newpage.php?id=$yourid">";

good luck

ptmi
04-29-2006, 07:55 PM
I'm getting the error below when using the code above.
Parse error: parse error, unexpected $ in path/newpage.php on line 3

trib4lmaniac
04-29-2006, 09:07 PM
not sure what you want but if you want to send users from page.php?id=1a2b3c to newpage.php?id=1a2b3c then maybe this might work if you paste this in page.php


$yourid=$_GET["id"];
echo "<meta http-equiv=\"Refresh\" content=\"0;url=newpage.php?id=$yourid">";

good luck
Or simply (in page.php):

header('Location: newpage.php?' . $_SERVER['QUERY_STRING']);

ptmi
04-30-2006, 12:56 AM
This worked great.
I didnt want to add another line in my htaccess file.


header('Location: newpage.php?' . $_SERVER['QUERY_STRING']);

Thank you very much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum