sqishy Posted December 6, 2008 Share Posted December 6, 2008 I don't know If i just have the syntax wrong or what but i am trying to send a variable through the header and it will not work. current code... //send user to topic header("Location: showtop.php?t_id=".$_POST["t_id"]."&rt="); The above works. Below is what i am trying to do. header("Location: showtop.php?t_id=".$_POST["t_id"]."&rt=".$_GET['rt']); I put $_GET['rt'] into a variable and it echo the correct value, but when i place it in this line of code to go to the header the URL shows up without the 'rt' value. So i don't know if the sentax is wrong or what. Please help example of what shows in URL "showtop.php?t_id=8&rt= " Quote Link to comment https://forums.phpfreaks.com/topic/135753-header-with-variable-problem/ Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 Well, <?php header("Location: showtop.php?t_id=".$_POST["t_id"]."&rt=".$_GET['rt']); ? The $_POST[] has " instead of ' Quote Link to comment https://forums.phpfreaks.com/topic/135753-header-with-variable-problem/#findComment-707315 Share on other sites More sharing options...
sqishy Posted December 6, 2008 Author Share Posted December 6, 2008 hmm The $_POST[] seems to work with " or ' but the problem is the $_GET for some reason with either of ' or " it still will not send the value with the url. Quote Link to comment https://forums.phpfreaks.com/topic/135753-header-with-variable-problem/#findComment-707329 Share on other sites More sharing options...
Philip Posted December 6, 2008 Share Posted December 6, 2008 What does this output: <?php $tempVar = 'showtop.php?t_id='.$_POST['t_id'].'&rt='.$_GET['rt']; echo $tempVar; //header("location: $tempVar"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135753-header-with-variable-problem/#findComment-707331 Share on other sites More sharing options...
peranha Posted December 6, 2008 Share Posted December 6, 2008 try setting a variable with the $_get value and see if that works. $rt = $_GET['rt']; then use $rt in the redirect. or try this header ("Location: showtop.php?t_id=$_POST[t_id]&rt=$_GET[rt]"); Quote Link to comment https://forums.phpfreaks.com/topic/135753-header-with-variable-problem/#findComment-707332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.