Problem with header

From: Date: Wed, 24 Mar 2004 23:17:31 +0000
Subject: Problem with header
Groups: php.general 
Request: Send a blank email to php-general+get-181437@lists.php.net to get a copy of this message
Hello to all - just joined this list to see if I can enhance my pretty slim knowledge of PHP. I have a little script I cobbled together than I modified to use as a guestbook for a client's site. I am trying to get the script to call a "success" page if the mail in fact gets sent. I plan to also add a "failure" page if the validation routine (haven't added this yet) doesn't work. I have been experimenting with the statement header("Location:thanks.shtml"); But no matter where I place it in the PHP file, I get the error message that says "Headers already sent..." To wit: <? include ("/file with passwords and user id's in it"); //a bunch of stuff to pull email recipient's address and id out of MySQL db //works fine //$enjoy, $visit, $test vars pulled from form that follows the script, no probs there $recipient=$to_name; $message=$enjoy.$visit.$text; $params['sendmail_path'] = '/usr/sbin/sendmail'; if ($submit){ mail($recipient, $subject, $message, "From:\"$from_name\"<$from_email>\r\n" . "Reply-to: $from_email\r\n" . "X-Mailer: PHP/" . phpversion()); } ?> So where in the world does the header("Location:thanks.shtml"); statement go? And if I do an if/else thing on submit, where does the other statement go? header("Location:error.shtml"); TIA for any advice you can offer. I must be really missing the point here. Cheers --- Phil Matt

« previous php.general (#181437) next »