Jump to content

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  :'(
Link to comment
https://forums.phpfreaks.com/topic/13341-driving-me-nuts-did-i-find-a-bug-help/
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]
[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 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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.