Note that there are some explanatory texts on larger screens.

plurals
  1. POE-mailing form data with php
    primarykey
    data
    text
    <p>I have serached through previous questions and have had no luck finding the answer.</p> <p>I want to simply send the imformation from my form to be e-mailed to me.here is my code for form.</p> <pre><code>&lt;form action="http://bikesnwines.com/html_form_send.php" method="post" name="form1"&gt; &lt;strong&gt;Your Details:&lt;/strong&gt;Full name: &lt;input type="text" maxlength="50" name="fullname" size="30" /&gt; E-mail Address: &lt;input type="text" maxlength="50" name="email_from" size="30" /&gt;Date of Visit: &lt;input type="text" maxlength="50" name="date" size="30" /&gt; &lt;strong&gt;Accomodation:&lt;/strong&gt; &lt;a href="http://www.bikesnwines.com/wp-content/uploads/2013/07/val-du-charron- 12+-1.jpg"&gt;&lt;img class="size-medium wp-image-1382 alignnone" alt="val-du-charron-12+ (1)" src="http://www.bikesnwines.com/wp-content/uploads/2013/07/val-du-charron-12+-1- 300x125.jpg" width="400" height="170" /&gt;&lt;/a&gt; &lt;p style="text-align: left;"&gt;&lt;strong&gt;&lt;a title="Val Du Charron" href="http://vdcwines.com/" target="_blank"&gt;Val Du Charron Wine Estate&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p style="text-align: left;"&gt;&lt;strong&gt;Length of Stay:&lt;/strong&gt;1 Night Stay only&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p style="text-align: left;"&gt;&lt;strong&gt;Optional Extra's:&lt;/strong&gt;&lt;/p&gt; &lt;p style="text-align: left;"&gt;&lt;input type="checkbox" name="extra1" value="MTB" /&gt;Mountain Biking Tours&lt;input type="checkbox" name="extra1" value="Spa" /&gt;Spa Treatements&lt;input type="checkbox" name="extra1" value="Olive" /&gt;Olive Grove Tour and Tasting&lt;input type="checkbox" name="extra1" value="Fishing" /&gt;Bass Fishing&lt;input type="checkbox" name="extra1" value="HorseRide" /&gt;Horse Riding&lt;/p&gt; &lt;strong&gt;Cycling Levels:&lt;/strong&gt; &lt;input type="radio" name="difficulty" value="Relaxed" /&gt;Relaxed &lt;input type="radio" name="difficulty" value="Moderate" /&gt;Moderate &lt;input type="radio" name="difficulty" value="Challenging" /&gt;Challenging &lt;strong&gt;Transport:&lt;/strong&gt; &lt;input type="radio" name="transport" value="Car Hire" /&gt;Car Hire &lt;input type="radio" name="transport" value="Transfers" /&gt;Airport or other Transfers &lt;input type="radio" name="transport" value="Self Drive" /&gt;Self Drive Comments: &lt;textarea cols="25" maxlength="1000" name="comments" rows="6"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Enquire Now" /&gt; &lt;/form&gt; </code></pre> <p>and the php I am using</p> <pre><code>&lt;?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "bookings@bikesnwines.com"; $email_subject = "Wellington Overnight Requests"; 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.&lt;br /&gt;&lt;br /&gt;"; echo $error."&lt;br /&gt;&lt;br /&gt;"; echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;"; die(); } // validation expected data exists if(!isset($_POST['fullname']) || isset($_POST['email_from']) || isset($_POST['date']) || isset($_POST['extra1']) || !isset($_POST['difficulty']) || !isset($_POST['transport']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $fullname = $_POST['fullname']; // required $email_from = $_POST['email_from']; // required $date = $_POST['date']; // required $extra1 = $_POST['extra1']; // not required $difficulty = $_POST['difficulty']; // required $transport = $_POST['transport']; // required $comments = $_POST['comments']; // not 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.&lt;br /&gt;'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$fullname)) { $error_message .= 'The First Name you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($error_message) &gt; 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($fullname)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Date of Stay: ".clean_string($date)."\n"; $email_message .= "Optional Extra's: ".clean_string($extra1)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); //redirect to thank for registering page header( 'Location: http://raceinterface.co.za/thank-you-for-registering/' ) ; } ?&gt; </code></pre> <p>when you submit it just opens a blank page.. I'm a bit blonde.. but super stuck..</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload