|
Posted by Jerry Stuckle on 05/14/07 15:03
Martien van Wanrooij wrote:
>
> "purcaholic" <purcaholic@googlemail.com> schreef in bericht
> news:1179068159.700014.8640@w5g2000hsg.googlegroups.com...
>> header("Location: ./meerinfo.php");
>> exit;
>> [/snap]
>>
>> The redirectiom should done before any output is send to client.
> Thank you purcaholic, both Jerry's and your suggestions give me a good
> idea about how to handle it.
> BTW the meerinfo.php in my example is a page that shows the article and
> that contains a link to the shopping cart. I suppose that the procedure
> you suggest is that "add to shopping cart" should be handled by a script
> "cart_handler.php" and that "cart_handler.php" should be redirected to
> "showshoppingcart.php" ?
> One more question: is the "exit" statement required or advisable even
> when a header(Location.. statement just has been executed?
>
>
> Thx again,
> Martien.
That sounds like a good solution.
As for the exit() - it's not required in all circumstances. What it
does is stop execution of the script immediately. If, for instance, the
redirect is the last thing in the file, exit() doesn't do anything good
or bad. However, if it's earlier in the file and you have other code
which might be executed, you want to call it (if you wanted to execute
the rest of the code you shouldn't be calling header() this early, anyway).
So it's not absolutely required - but I normally put it in to ensure any
further code isn't executed. And I normally put it at the end, also -
just for consistency (and in case I add more stuff later).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|