Return to Snippet

Revision: 30123
at August 8, 2010 07:55 by sandman7OR


Initial Code
<?php 

$fields = array(); 
$fields{"Name"} = "Name"; 
$fields{"Email"} = "Email";   
$fields{"Message"} = "Message"; 

$to = "[email protected]" ; 
$from = $_REQUEST['Email'] ; 
$name = $_REQUEST['Name'] ; 
$headers = "From: $from"; 
$subject = "NCCDC Web contact -- From contact page"; 

$body = "WEB CONTACT FROM NCCDC \n\n We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 

/*Second email */
$headers2 = "From: [email protected]"; 
$subject2 = "Thank you for contacting NCCDC"; 
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at www.pdxchild.org";
               $autoreply .= "\n\n You Wrote: \n".$_REQUEST["Message"];

if($from == '') {print "You have not entered an email, please go back and try again";} 
else { 
if($name == '') {print "You have not entered a name, please go back and try again";} 
else { 
$send = mail($to, $subject, $body, $headers); 
$send2 = mail($from, $subject2, $autoreply, $headers2); 
if($send) 
{header( "Location: ../thankyou/" );} 
else 
{print "We encountered an error sending your mail, please notify [email protected]"; } 
}
}
?>

Initial URL


Initial Description
processes contact form input and produces an auto reply

Initial Title
Basic Form Handler

Initial Tags
forms

Initial Language
PHP