Jump to content

Archived

This topic is now archived and is closed to further replies.

ssmK

Driving me nuts ...did I find a bug!? Help!!

Recommended Posts

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=d

Now, 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  :'(

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

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
}

?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.