My email form script

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed May 25, 2011 1:00 pm

My email form script

Postby SuperWebman » Wed May 25, 2011 1:04 pm

Hey everyone I'm pretty new at PHP so i'm hoping someone can help me with this code. What I am trying to do is if someone selects a state say Kansas then fills out the rest of the form and clicks submit it will go to a specific email address. If someone selects another state like Nebraska it will go to a separate email address. Here is my code and I hope someone can help me with this.

PS I think I really screwed this one up lol :help:



Code: Select all


/* Subject and Email variables */

 $emailSubject = 'Your Car Report Info.';
 $webMaster = '';
 $webMaster2 ='';
 $webMaster3 ='';
 /* Gathering Data Variables */
 $f_nameField = $_POST['f_name'];
 $l_nameField = $_POST['l_name'];
 $addField = $_POST['Address'];
 $stateField = $_POST['state'];
 $phoneField = $_POST['phone'];
 $emailField = $_POST['email'];
 $vinField = $_POST['vin'];
 $body = <<<EOD
First Name: $f_name <br>
Last Name: $l_name <br>
Address: $Address <br>
State: $state <br>
Phone: $phone <br>
Email: $email <br>
VIN: $vin <br>

switch($state) {
  case 'Kansas':
  case 'Oklahoma':
    $wm = $webMaster2;
  case 'Missouri':
  case 'Iowa':
    $wm = $webMaster3;
  case 'Nebraska:
    $wm = $webMaster;

 $headers = "From: $email\r\n";
 $headers .= "Content-type: text/html\r\n";
$success = mail($wm, $emailSubject, $body, $headers);
 /* Results rendered from Html */
 $theResults = <<<EOD
<title>Your Car Report - Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">

body {
   background-color: #f1f1f1;
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   font-style: normal;
   line-height: normal;
   font-weight: normal;
   color: #666666;
   text-decoration: none;


  <div align="center">Thank you for your submission. Your vehicle report will be provided to you very soon!</div>

 echo "$theResults";

Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests