Hi, Friday, March 26, 2004, 2:36:18 PM, you wrote:
pen> On 25 Mar 2004 at 14:10, Tom Rogers wrote: >> >> Any whitespace in any file before the <?php will cause data to be sent >> to the browser forcing the headers to be sent. So make sure the first >> line of your page has <?php and it is a good idea to drop the ?> from >> included pages as there may be blank lines following which are just as >> bad. So the rule is, header() can go anywhere but before any output to >> the browser. >> pen> and also >> One other little rule: get into the habit of putting the full url in >> location, it will save you grief down the line :) >> >> To redirect to the same page for example >> >> $url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; >> header("Location: $url"); >> pen> Thanks, Tom! That did the trick. I began the file with the <? as it pen> appears that for a web page that has a lot of ordinary HTML on it, pen> the PHP must begin BEFORE even the Doc Type line. pen> I have a question about just how the PHP headers work; I have looked pen> around in the PHP manual, but I am still not quite clear on this. pen> I want to follow this logic when the user fills out the guestbook and pen> clicks on the "submit" button. Is the following the general idea? (I pen> have not tried to use the proper syntax, just want to know if the pen> general logic is sound): pen> if $submit //if the user has clicked the submit button pen> then pen> check that the form is filled out correctly // validation routine pen> if $notvalid then header("Location: $badform"); pen> else pen> check the URL's// make sure spammers are not trying to co-opt script pen> if $urlfail then header("Location: $urlfail"); pen> else pen> send the mail, redirect to thank you page // pen> header("Location: $url"); pen> $url = "http://www.whatever.com/thanks.shtml"; pen> $urlfail ="http://www.whatever.com/warning.shtml"; pen> $urlbadform="http://www.whatever.com/error.shtml"; pen> Is that the way to use multiple headers for conditional statements? pen> TIA --- Phil Matt Yes that logic should work fine, and it will also stop the refresh warning from the browser and help prevent multiple submissions. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php