Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

My email form script

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

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:

Thanks,

B
Code: Select all
<?php

/* Subject and Email variables */

 $emailSubject = 'Your Car Report Info.';
 $webMaster = 'me@rustyeckford.com';
 $webMaster2 ='me1@rustyeckford.com';
 $webMaster3 ='me2@rustyeckford.com';
 
 /* 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
<br><hr><br>
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>
EOD;

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


 $headers = "From: $email\r\n";
 $headers .= "Content-type: text/html\r\n";
 
$success = mail($wm, $emailSubject, $body, $headers);
 
 /* Results rendered from Html */
 
 $theResults = <<<EOD
<html>
<head>
<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;
}

</style>
</head>

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



 echo "$theResults";
 
 
?>
SuperWebman
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed May 25, 2011 1:00 pm

Return to Your Scripts

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron