ssmK Posted June 30, 2006 Share Posted June 30, 2006 Hey, I'm working on a script that redirects after a form has been submitted. Here's the problem:The page the user is redirected to uses $_GET[] variables like this:Example:[filename].php?s=100&np=3&sort=dNow, the page uses the header(); function to pass the URL. The problem is that header will NOT pass the numbers, it redirects me to this page:[filename].php?s=&np=&sort= (<-- no values)I have assigned the URL to a variable and have used echoes to be 100% positive the string which header(); is using does in fact have the numbers in there. Somehow the values are getting cut out. Have I discovered some new bug, am I missing the incredibly obvious?? Help :'( Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/ Share on other sites More sharing options...
jworisek Posted June 30, 2006 Share Posted June 30, 2006 post the code for it Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51446 Share on other sites More sharing options...
ssmK Posted June 30, 2006 Author Share Posted June 30, 2006 [code]<?php$s=$_GET['s'];$np=$_GET['np'];$sort=$_GET['sort'];$url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/view_items.php?s='.$s.'&np='.$np.'&sort='.$sort;$header = 'Location: '.$url;header($header); //This produces problem described?><a href="<?php echo $url; ?>">Click</a> //This takes me right where I need to go[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51451 Share on other sites More sharing options...
ssmK Posted June 30, 2006 Author Share Posted June 30, 2006 btw, this echoes TRUE ....[code]<?php if ('Location: http://127.0.0.1/oti/view_items.php?s=100&np=3&sort=d'==$header){echo 'TRUE';} ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51452 Share on other sites More sharing options...
jworisek Posted June 30, 2006 Share Posted June 30, 2006 headers should be called like this:[code]header (Location: "http://www.blahblah.com");[/code]yours is printed as this:[code]header (Location: http://www.blahblah.com);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51453 Share on other sites More sharing options...
SharkBait Posted June 30, 2006 Share Posted June 30, 2006 Wierd because I do the same thing you do with no issues:[code]header("Location: ". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."myfile.php?id=3&num=45");exit();[/code]Seems to work for me :) Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51454 Share on other sites More sharing options...
ssmK Posted June 30, 2006 Author Share Posted June 30, 2006 [quote author=jworisek link=topic=99049.msg389911#msg389911 date=1151705270]headers should be called like this:[code]header (Location: "http://www.blahblah.com");[/code]yours is printed as this:[code]header (Location: http://www.blahblah.com);[/code][/quote]Thank you for the reply, however, this is different from how my book describes header(); usage. I tried this anyway, and it doesn't work. Thank though. Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51458 Share on other sites More sharing options...
ssmK Posted June 30, 2006 Author Share Posted June 30, 2006 [quote author=SharkBait link=topic=99049.msg389912#msg389912 date=1151705377]Wierd because I do the same thing you do with no issues:[code]header("Location: ". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."myfile.php?id=3&num=45");exit();[/code]Seems to work for me :)[/quote]Works for me too, but it doesn't work if you actually put variables in there. Works just fine entering it as plain text. Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51459 Share on other sites More sharing options...
ssmK Posted July 1, 2006 Author Share Posted July 1, 2006 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51496 Share on other sites More sharing options...
redarrow Posted July 1, 2006 Share Posted July 1, 2006 test.php<?header("location: filename.php?&s=100&np=3&sort=d");?>test_result.php<?if(!$_GET['s']=='100') {do some think}elseif(!$_GET['np']=='3') {do somethink}elseif(!$_GET['sort']=='d') {do some think}?> Quote Link to comment https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/#findComment-51499 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.