header function, I'm stumped
| From: | Chris Hubbard | Date: | Tue, 02 Dec 2003 19:02:35 +0000 |
| Subject: | header function, I'm stumped | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-171603@lists.php.net to get a copy of this message | ||
All,
dealing with header("location:...") again. and trying to understand what's
happening.
I've got the following code:
writeMessage($id);
header("Location:http://www.mysite.com/cp/ad/ad_details.php?id=".
$id);
writeMessage() is a debugging function that writes the value of the variable
to a debug log. When the code is run $id does have a valid value like 8 or
12.
When I run the code, it does not redirect to the specified location, it
continues executing the code.
So I add the exit; and it does work:
writeMessage($id);
header("Location:http://www.mysite.com/cp/ad/ad_details.php?id=".
$id);
exit;
What's weird is the same code without the exit works on a different server
(and indeed the same code with different location works on this server)
I thought perhaps it was due to type problem, but code doesn't work if $id
is a string or integer.
The flow for the code:
start the edit page
when edit page is submitted,
check the data,
if data is good,
update the database
redirect to details page
if data is bad,
return to the edit page
Then I used LiveHTTPHeaders in Mozilla and it give me some interesting
information, though I'm not quite sure how to interpret.
Can someone provide some depth to the mechanisms within the
header(location)?
Thanks in advance,
Chris Hubbard
chris@wildcharacters.com
www.wildcharacters.com
425 481 2020
php based web application development
[[ check out phalidate, a data validation class ]]
Y! hoponpopontoponmoponcop@yahoo.com
MSN another_ganesha@hotmail.com
AIM ganeshacph