This is a discussion on Help with mail script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I use the script below to send a email from a contact form but it would be nice if ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi, I use the script below to send a email from a contact form but it would be nice if the conformed sent page showed what was sent.Question how can I do this ? Thanks Chris <?php $mailto = 'email@mail.co' ; $subject = "Feedback Form" ; $formurl = "http://page.co/ of form" ; $errorurl = "http://page.co/contact.php" ; $thankyouurl = "http://page.co/thankyou.php" ; $uself = 1; $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $name = $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (empty($name) || empty($email) || empty($comments)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid referrer"); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $name\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: Feed Back" ); header( "Location: $thankyouurl" ); exit ; ?> |
|
|||
|
Joker7 schreef:
> Hi, > I use the script below to send a email from a contact form but it would be > nice if the conformed sent page showed what was sent.Question how can I do > this ? > > Thanks > Chris > > <?php > $mailto = 'email@mail.co' ; > $subject = "Feedback Form" ; > $formurl = "http://page.co/ of form" ; > $errorurl = "http://page.co/contact.php" ; > $thankyouurl = "http://page.co/thankyou.php" ; > $uself = 1; > $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; > $name = $_POST['name'] ; > $email = $_POST['email'] ; > $comments = $_POST['comments'] ; > $http_referrer = getenv( "HTTP_REFERER" ); > > if (!isset($_POST['email'])) { > header( "Location: $formurl" ); > exit ; > } > if (empty($name) || empty($email) || empty($comments)) { > header( "Location: $errorurl" ); > exit ; > } > if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { > header( "Location: $errorurl" ); > exit ; > } > > if (get_magic_quotes_gpc()) { > $comments = stripslashes( $comments ); > } > > if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid > referrer"); > > } > > $messageproper = > > "This message was sent from:\n" . > "$http_referrer\n" . > "------------------------------------------------------------\n" . > "Name of sender: $name\n" . > "Email of sender: $email\n" . > "------------------------- COMMENTS -------------------------\n\n" . > $comments . > "\n\n------------------------------------------------------------\n" ; > > mail($mailto, $subject, $messageproper, > "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . > $headersep . "X-Mailer: Feed Back" ); > header( "Location: $thankyouurl" ); > exit ; > > ?> > > Hi, http://nl2.php.net/manual/en/function.mail.php says for returnvalue of your mail command: Quote:
$mailresult = mail(..yourstuffhere..); And then use the value for $mailresult to display if the sending was succesful. echo (($mailresult) ? "SUCCES!":"PROBLEM WITH SENDING" ); Regards, Erwin Moller |
![]() |
| Thread Tools | |
| Display Modes | |
|
|