Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* These are the variable that tell the subject of the email and where the email will be sent.*/
- $emailSubject = 'Customer Has a Question!';
- $mailto = 'meya@digihaul.com';
- /* These will gather what the user has typed into the fieled. */
- $nameField = $_POST['name'];
- $addressField = $_POST['address'];
- $cityField = $_POST['city'];
- $stateField = $_POST['state'];
- $zipField = $_POST['zip'];
- $phoneField = $_POST['phone'];
- $emailField = $_POST['email'];
- $contactField = $_POST['contact'];
- $serviceField = $_POST['service'];
- $questionField = $_POST['info'];
- /* This takes the information and lines it up the way you want it to be sent in the email. */
- $body = <<<EOD
- <br><hr><br>
- Name: $nameField <br>
- Phone: $phoneField <br>
- Email: $emailField <br>
- Adress: $addressField <br>
- City, State Zip: $cityField, $stateField $zipField <br>
- Contact Preference: $contactField <br>
- Service: $serviceField <br>
- Info: $questionField <br>
- EOD;
- echo $body;
- $headers = "From: $emailFieldrn"; // This takes the email and displays it as who this email is from.
- $headers .= "Content-type: text/htmlrn"; // This tells the server to turn the coding into the text.
- if (!preg_match("/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/", $emailField)) {
- echo "<h4>Invalid email address</h4>";
- echo "<a href='javascript:history.back(1);'>Back</a>";
- } elseif ($nameField == "") {
- echo "<h4>No Name</h4>";
- echo "<a href='javascript:history.back(1);'>Back</a>";
- }
- /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
- elseif (mail($mailto, $emailSubject, $body, $headers)) {
- echo "<h4>Thank you for sending email</h4>";
- }
- else {
- echo "<h4>Can't send email to $emailField</h4>";
- }
- ?>
- Name: Able Care
- Phone: 4175555555
- Email: meya@email.com
- Adress: 1205 S Fake Ave
- City, State Zip: Springfield, MO 65807
- Contact Preference: email
- Service: shrub
- Info: Data Entered
- Can't send email to meya@email.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement