Jump to content


Photo

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


  • Please log in to reply
9 replies to this topic

#1 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 30 June 2006 - 09:30 PM

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

#2 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 30 June 2006 - 09:33 PM

post the code for it

#3 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 30 June 2006 - 09:48 PM

<?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


#4 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 30 June 2006 - 09:56 PM

btw, this echoes TRUE ....
<?php if ('Location: http://127.0.0.1/oti/view_items.php?s=100&np=3&sort=d'==$header){echo 'TRUE';} ?>


#5 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 30 June 2006 - 10:07 PM

headers should be called like this:

header (Location: "http://www.blahblah.com");

yours is printed as this:

header (Location: http://www.blahblah.com);


#6 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 30 June 2006 - 10:09 PM

Wierd because I do the same thing you do with no issues:


header("Location: ". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."myfile.php?id=3&num=45");
exit();


Seems to work for me :)

#7 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 30 June 2006 - 10:43 PM

headers should be called like this:

header (Location: "http://www.blahblah.com");

yours is printed as this:

header (Location: http://www.blahblah.com);


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.

#8 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 30 June 2006 - 10:43 PM

Wierd because I do the same thing you do with no issues:


header("Location: ". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."myfile.php?id=3&num=45");
exit();


Seems to work for me :)


Works for me too, but it doesn't work if you actually put variables in there.  Works just fine entering it as plain text.

#9 ssmK

ssmK
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 01 July 2006 - 02:42 AM

Anyone?

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 July 2006 - 03:04 AM


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
}

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users