Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- My PHP form with an html <select> box that sends form to different emails isn't executing
- <?php
- $hostname = "db.example.com";
- $database = "poweri3_blank";
- $username = "script";
- $password = "xxxxxx";
- $conn = mysql_connect($hostname, $username, $password) or DIE("Unable to connect to database");
- $dbconnection = $conn;
- mysql_select_db($database) OR DIE("Unable to select database");
- /* Subject and Email Variables- */
- $emailSubject = 'Request for Provider';
- $webMaster = 'me@gmail.com';
- /*Gathering Data Variables*/
- $firstName = $_POST['firstName'];
- $lastName = $_POST['lastName'];
- $email = $_POST['email'];
- $zipCode = $_POST['zipCode'];
- $provider = $_POST['provider'];
- $comment = $_POST['comment'];
- //send e-mail to different providers
- if($provider=="p1") $sendTo = "p1@gmail.com";
- if($provider=="p2") $sendTo = "p2@gmail.com";
- if($provider=="p3") $sendTo = "p3@gmail.com";
- if($provider=="p4") $sendTo = "p4@gmail.com";
- $body = <<<EOD
- <br><hr><br>//--------CONTACT--------//<br><br>
- Name: $firstName $lastName<br><br>
- Email: $email<br><br>
- Cable or Satellite Provider: $provider<br><br>
- Zip/Postal Code: $zipCode<br><br>
- Your Message: $comment<br><br>
- EOD;
- $headers = "From: $emailrn";
- $headers .= "Content-type: text/htmlrn";
- $success = mail($webMaster,$emailSubject,$body,$headers);
- //Enter Data Into Table
- $sql = "INSERT INTO poweri3_blank.provider_contact (
- firstName,
- lastName,
- email,
- zip_code,
- provider,
- comment
- )
- VALUES(
- '".$firstName."',
- '".$lastName."',
- '".$email."',
- '".$zipCode."',
- '".$provider."',
- '".$comment."')";
- $result = mysql_query($sql) or die("Couldn't execute query: $sql");
- //$result = mysql_query($sql) or die(mysql_error());
- // Kill connection
- mysql_close($conn);
- /*Results rendered as HTML
- $theResults = <<<EOD
- <html>
- <head>
- <title>Yourpage title</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="left">Thank You For Your Interest. </div>
- </div>
- </body>
- </html>
- EOD;
- echo "$theResults";*/
- ?>
- //send e-mail to different providers
- if($provider=="p1") $sendTo = "p1@gmail.com";
- if($provider=="p2") $sendTo = "p2@gmail.com";
- if($provider=="p3") $sendTo = "p3@gmail.com";
- if($provider=="p4") $sendTo = "p4@gmail.com";
- $success = mail($webMaster,$emailSubject,$body,$headers);
- $success = mail($sendTo,$emailSubject,$body,$headers);
Add Comment
Please, Sign In to add comment