Hey guys,
Quick breakdown of the scenario... I've got a form, and my goal in the form_submitted.php file is to process the information, output a message, and redirect to a home page about 5 seconds after outputting the message. Now I could've sworn I've always learned that nothing should to output to a page when header() is used. However, I tried it just to see what kind of error I'd get, and to my surprise, it worked perfectly. What am I missing here?
Function header() working when it's not supposed to?!?
Moderator: General Moderators
Re: Function header() working when it's not supposed to?!?
The rule is to always send headers first before outputing data.
Code: Select all
<html>
<?php
// This results in an error.
// The output above is before the header() call
header('Location: http://www.example.com/');
?>
Re: Function header() working when it's not supposed to?!?
My bad, that's what I meant. So my point is I'm breaking that rule, but the code still works. Why?
Re: Function header() working when it's not supposed to?!?
Probably because you're using IE and they don't want granny's browser to say ERROR and stop working just because people don't follow good html rules.
Re: Function header() working when it's not supposed to?!?
I'm testing it on both IE and Firefox. It works on both.
Re: Function header() working when it's not supposed to?!?
same story, they are protecting people from their own ignorance. maybe the next version won't. Do you want your browser to break every time there is a missing closing html tag? Browers trade displaying errors every time there are missing tags or general sloppy html for functionality.
Re: Function header() working when it's not supposed to?!?
Great, thanks for your help.