Hi,

Thursday, March 25, 2004, 9:17:31 AM, you wrote:
PM> Hello to all - just joined this list to see if I can enhance
PM> my pretty slim knowledge of PHP.

PM> I have a little script I cobbled together than I modified to use as a guestbook 
for a
PM> client's site. I am trying to get the script to call a
PM> "success" page if the mail in fact gets 
PM> sent. I plan to also add a "failure" page if the validation
PM> routine (haven't added this yet) 
PM> doesn't work.

PM> I have been experimenting with the statement

PM> header("Location:thanks.shtml");

PM> But no matter where I place it in the PHP file, I get the error message that says
PM> "Headers already sent..."

PM> To wit:
PM> <? 
PM> include ("/file with passwords and user id's in it"); 
PM> //a bunch of stuff to pull email recipient's address and id out of MySQL db
PM> //works fine
PM> //$enjoy, $visit, $test vars pulled from form that follows the script, no probs 
there
PM> $recipient=$to_name;
PM> $message=$enjoy.$visit.$text;
PM> $params['sendmail_path'] = '/usr/sbin/sendmail';
PM> if ($submit){
PM> mail($recipient, $subject, $message,
PM> "From:\"$from_name\"<$from_email>\r\n" .
PM> "Reply-to: $from_email\r\n" .       
PM> "X-Mailer: PHP/" . phpversion());
PM>    }
?>>

PM> So where in the world does the

PM> header("Location:thanks.shtml");

PM> statement go? And if I do an if/else thing on submit, where does the other 
statement go?

PM> header("Location:error.shtml");

PM> TIA for any advice you can offer. I must be really missing the point here.

PM> Cheers --- Phil Matt


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.

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to