Search the Community
Showing results for tags 'online form'.
-
I'm busy building an online html form that posts to a *.php file (Below). Were do I add in a line of code that sends the subscribe a copy of the completed form. On another note, the form successfully post when completed, but the client informed us that we hasn't received a copy - is there anything I'm missing? <?php if(isset($_POST['email'])) { $email_to = "EmailTo"; $email_subject = "Online Booking Form"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['company_name']) || !isset($_POST['email']) || !isset($_POST['booking_date']) || !isset($_POST['session_times']) || !isset($_POST['number_players']) || !isset($_POST['confirmation_code'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $company_name = $_POST['company_name']; // not required $email_from = $_POST['email']; // required $booking_date = $_POST['booking_date']; // required $session_times = $_POST['session_times']; // required $number_players = $_POST['number_players']; // required $confirmation_code = $_POST['confirmation_code']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Online Booking Results.\r\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\r\n"; $email_message .= "Last Name: ".clean_string($last_name)."\r\n"; $email_message .= "Your Company: ".clean_string($company_name)."\r\n"; $email_message .= "Email Address: ".clean_string($email_from)."\r\n"; $email_message .= "Booking Date: ".clean_string($booking_date)."\r\n"; $email_message .= "Session Times: ".clean_string($session_times)."\r\n"; $email_message .= "Number of Players: ".clean_string($number_players)."\r\n"; $email_message .= "Confirmation Code: ".clean_string($confirmation_code)."\r\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(). "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; ini_set("SMTP","IPADDRESS"); ini_set("smtp_port", "25"); ini_set("sendmail_from", "SendFrom"); ini_set('auth_username','Username'); ini_set('auth_password','Password'); @mail($email_from, $email_subject, $email_message, $headers); @mail($email_to, $email_subject, $email_message, $headers); header('Location: URL'); ?> <?php } ?>