Guest User

Untitled

a guest
Aug 23rd, 2018
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. My PHP form with an html <select> box that sends form to different emails isn't executing
  2. <?php
  3. $hostname = "db.example.com";
  4. $database = "poweri3_blank";
  5. $username = "script";
  6. $password = "xxxxxx";
  7. $conn = mysql_connect($hostname, $username, $password) or DIE("Unable to connect to database");
  8. $dbconnection = $conn;
  9. mysql_select_db($database) OR DIE("Unable to select database");
  10.  
  11. /* Subject and Email Variables- */
  12. $emailSubject = 'Request for Provider';
  13. $webMaster = 'me@gmail.com';
  14.  
  15. /*Gathering Data Variables*/
  16. $firstName = $_POST['firstName'];
  17. $lastName = $_POST['lastName'];
  18. $email = $_POST['email'];
  19. $zipCode = $_POST['zipCode'];
  20. $provider = $_POST['provider'];
  21. $comment = $_POST['comment'];
  22.  
  23. //send e-mail to different providers
  24. if($provider=="p1") $sendTo = "p1@gmail.com";
  25. if($provider=="p2") $sendTo = "p2@gmail.com";
  26. if($provider=="p3") $sendTo = "p3@gmail.com";
  27. if($provider=="p4") $sendTo = "p4@gmail.com";
  28.  
  29. $body = <<<EOD
  30. <br><hr><br>//--------CONTACT--------//<br><br>
  31. Name: $firstName $lastName<br><br>
  32. Email: $email<br><br>
  33. Cable or Satellite Provider: $provider<br><br>
  34. Zip/Postal Code: $zipCode<br><br>
  35. Your Message: $comment<br><br>
  36. EOD;
  37.  
  38. $headers = "From: $emailrn";
  39. $headers .= "Content-type: text/htmlrn";
  40. $success = mail($webMaster,$emailSubject,$body,$headers);
  41.  
  42. //Enter Data Into Table
  43. $sql = "INSERT INTO poweri3_blank.provider_contact (
  44. firstName,
  45. lastName,
  46. email,
  47. zip_code,
  48. provider,
  49. comment
  50. )
  51. VALUES(
  52. '".$firstName."',
  53. '".$lastName."',
  54. '".$email."',
  55. '".$zipCode."',
  56. '".$provider."',
  57. '".$comment."')";
  58.  
  59. $result = mysql_query($sql) or die("Couldn't execute query: $sql");
  60. //$result = mysql_query($sql) or die(mysql_error());
  61.  
  62. // Kill connection
  63. mysql_close($conn);
  64.  
  65. /*Results rendered as HTML
  66.  
  67.  
  68. $theResults = <<<EOD
  69. <html>
  70. <head>
  71. <title>Yourpage title</title>
  72. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  73. <style type="text/css">
  74. <!--
  75. body {
  76. background-color: #f1f1f1;
  77. font-family: Verdana, Arial, Helvetica, sans-serif;
  78. font-size: 12px;
  79. font-style: normal;
  80. line-height: normal;
  81. font-weight: normal;
  82. color: #666666;
  83. text-decoration: none;
  84. }
  85. -->
  86. </style>
  87. </head>
  88.  
  89. <div>
  90. <div align="left">Thank You For Your Interest. </div>
  91. </div>
  92. </body>
  93. </html>
  94. EOD;
  95.  
  96.  
  97. echo "$theResults";*/
  98. ?>
  99.  
  100. //send e-mail to different providers
  101. if($provider=="p1") $sendTo = "p1@gmail.com";
  102. if($provider=="p2") $sendTo = "p2@gmail.com";
  103. if($provider=="p3") $sendTo = "p3@gmail.com";
  104. if($provider=="p4") $sendTo = "p4@gmail.com";
  105.  
  106. $success = mail($webMaster,$emailSubject,$body,$headers);
  107.  
  108. $success = mail($sendTo,$emailSubject,$body,$headers);
Add Comment
Please, Sign In to add comment