betabr2005 Posted June 14, 2008 Share Posted June 14, 2008 Hi all, I am a totally newbie to php but I have done some search in google and here in the forum before deciding to post it. Even all this I could not figure out what is wrong in my php form. The logic is an html form that send info to a php page where verification and an email is sent. Everytime I fill the form and click in submit, it will display the following: " " Warning: mail(): Bad parameters to mail() function, mail not sent. in /home/content/I/T/F/ITFXadmin/html/site/submit.php on line 135 Mail not sent this time. And the form itself will be displayed funky, text not in the right position in the screen. To verify how it is now, please go to http://www.tandbelectricco.com/site/form.html Please, feel free to play with the form here and check the result I am getting. The code for the php is the following: 1. 2. <?php 3. /* 4. if (!isset($_POST['form1'])) { 5. echo "<h1>Error</h1>n 6. <p>Accessing this page directly is not allowed.</p>"; 7. exit; 8. } 9. */ 10. function cleanUp($data) { 11. $data = trim(strip_tags(htmlspecialchars($data))); 12. return $data; 13. } 14. 15. $name = cleanUp($_POST['name']); 16. $po = cleanUp($_POST['po']); 17. $email = cleanUp($_POST['email']); 18. $work = cleanUp($_POST['work']); 19. $state = cleanUp($_POST['state']); 20. $phone = cleanUp($_POST['phone']); 21. $fax = cleanUp($_POST['fax']); 22. $cell = cleanUp($_POST['cell']); 23. $city = cleanUp($_POST['city']); 24. $zip = cleanUp($_POST['zip']); 25. $response_time = cleanUp($_POST['response_time']); 26. $work_performed = cleanUp($_POST['work_performed']); 27. $clean_safe = cleanUp($_POST['clean_safe']); 28. $service = cleanUp($_POST['better_service']); 29. ?> 30. 31. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 32. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 33. <head> 34. <title>T & B Electric Co. Inc.</title> 35. <link href="style.css" rel="stylesheet" type="text/css" /> 36. <link href="layout.css" rel="stylesheet" type="text/css" /> 37. <script src="maxheight.js" type="text/javascript"></script> 38. <meta name="keywords" content="T & B Electric Co, electrical contractors, electricians, electrical services, Crofton, Maryland, celular communications, 39. electrical instalation, cellular site, electrical building maintenance, thermal imaging, technical consulting, electrical distribution relocation, electical 40. wiring, emergency electrical service, licensed electricians, NECA, National Electrical Contractors Association, State Master Electrical, east coast, commercial, 41. telecommunications, grounding protection services, electrical market, telecommunications carriers, electrical equipment, 24 x 7 emergency service, power 42. emergency service, power emergency, power company, electrical failure, power outages" /> 43. <meta name="decription" content="T&B Electric Co is a medium sized electrical contractor located in Crofton , MD , licensed to serve the east coast. The company services 44. include commercial, electrical services and cell communications, including safety programs, green sustainable technology, full electrical services, 24 x 7 emergency 45. services, electrical installation in cellular sites. T&B Electric Co. 301-261-0755." /> 46. </head> 47. 48. <body id="page5" onload="new ElementMaxHeight();"> 49. <div id="site_center"> 50. <div class="tall_top"> 51. <div class="tall_bottom"> 52. <div id="main"> 53. <!-- header --> 54. <div id="header"> 55. <div class="row_1"> 56. <div class="fleft"> 57. <h1><img src="images/logo_TB.gif" alt="" width="143" height="75" /></h1> 58. </div> 59. <div class="fright"> 60. <div class="indent"> 61. <div class="header_but"> 62. <div class="left"> 63. <div class="right"> 64. <div class="ind"> 65. <a class="link1" href="sitemap.html">Sitemap</a> <!-- :: <a class="link1" href="#">Login</a>--> 66. </div> 67. </div> 68. </div> 69. </div> 70. </div> 71. </div> 72. <div class="clear"></div> 73. </div> 74. <div class="row_2"> 75. <div class="indent"> 76. <a href="index.html">Home</a><img alt="" src="images/spacer.gif" width="64" height="1" /><a href="aboutus.html">About Us</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="licenses.html">Licenses</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="services.html">Services</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="customerservices.html">Customer Service </a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="feedback.html">Feedback</a><!--<img alt="" src="images/spacer.gif" width="64" height="1"/><a href="index-6.html">FAQ</a>--><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="contactus.html">Contact Us</a><br /> 77. </div> 78. </div> 79. <div class="row_3"> 80. <div class="indent"> <br /> 81. </div> 82. </div> 83. </div> 84. <!-- content --> 85. <div><br style="line-height:18px;" /> 86. </div> 87. <div id="content"> 88. <div class="col_1 maxheight"> 89. <div class="indent"> 90. <h2><img alt="" src="images/5_t1.gif" /></h2> 91. <div class="indent1"> 92. <p class="title">Feedback</p> 93. <h3>We want to hear from you.</h3> 94. <p> T&B Electric Co has as business strengths the quality of service its personnel provides its clients for maintaining equipment and facilities in highly standard operating condition due to systematic inspection, detection, and correction of incipient failures either before they occur or before they develop into major defects. Our maintenance programs include tests, measurements, adjustments, and parts replacement, performed specifically to prevent faults from occurring. </p> 95. <p> If you are our client or had any service provided by T & B Electric Co., we want to hear from you. Send us your feedback on the service experience you had. We will be glad to hear from you. </p> 96. 97. 98. <img src="images/kitchen.jpg" alt="" width="249" height="187" class="img_indent" /> 99. <div class="clear"></div> 100. 101. </div> 102. </div> 103. </div> 104. <div class="col_2 maxheight"> 105. <div class="indent"> 106. <h2><img alt="" src="images/5_t2.gif" /></h2> 107. <div class="indent1"> 108. <h2 class="red">Send us your feedback.</h2> 109. 110. <form id="form1" action="submit.php" method="post"> 111. <p> 112. <div class="container">" 113. <div class="column1">" 114. <?php 115. $recipient = "[email protected] \n"; 116. $subject = "feedback website submission form \n"; 117. 118. $message = "Name: $name \n"; 119. $message .= "PO#: $po \n"; 120. $message .= "E-mail: $email \n"; 121. $message .= "Work address: $work \n"; 122. $message .= "State: $state n"; 123. $message .= "Work Performed: $response_time \n"; 124. $message .= "Phone: $phone \n"; 125. $message .= "Fax: $fax \n"; 126. $message .= "Cell: $cell \n"; 127. $message .= "City: $city \n"; 128. $message .= "Zip: $zip \n"; 129. $message .= "Work Performed Efficiently: $work_performed \n"; 130. $message .= "Site left clean and safe: $clean_safe \n"; 131. $message .= "How can we better serve you: $better_service \n"; 132. 133. $headers = "From: $email \n"; 134. $headers .= "Reply-To: $email \n"; 135. 136. if (mail($recipient,$subject,$message,$headers)) { 137. echo "<p>Mail sent successfully.</p>"; 138. } else { 139. echo "<p>Mail not sent this time.</p>"; 140. } 141. ?> 142. 143. Name*:<br /><div class="form"><input type="text" name="name" /></div> 144. PO#:<br /><div class="form"><input type="text" name="po" /></div> 145. E-mail address*:<br /><div class="form"><input type="text" name="email" /></div> 146. <h3>Work Address.</h3>Street:<br /><div class="form"><input type="text" name="work" /></div> 147. State:<br /><div class="form"><input type="text" name="state" /></div> 148. Response time*:<br /><div><input class="radio" type="radio" value="excellent" name="response_time"/>Excellent<br /> 149. <input class="radio" type="radio" value="good" name="response_time"/>Good<br /> 150. <input class="radio" type="radio" value="fair" name="response_time"/>Fair<br /> 151. <input class="radio" type="radio" value="need_improvement" name="response_time"/>Need Improvement<br /></div></div> 152. <div class="column2" style="float:right;"> 153. Phone*:<br /><div class="form"><input type="text" value="phone" /></div> 154. Fax:<br /><div class="form"><input type="text" value="fax" /></div> 155. Cell:<br /><div class="form"><input type="text" value="cell" /></div><br /> 156. City:<br /><div class="form"><input type="text" value="city" /></div> 157. Zip:<br /><div class="form"><input type="text" value="zip" /></div> 158. Work performed efficiently*:<br /><div><input class="radio" type="radio" value="yes_efficient" name="work_performed"/>Yes<br /> 159. <input class="radio" type="radio" value="no_efficient" name="work_performed"/>No<br /></div> 160. Was site left clen and safe?*<br /><div><input class="radio" type="radio" value="yes_clean" name="clean_safe"/>Yes<br /> 161. <input class="radio" type="radio" value="no_clean" name="clean_safe"/>No<br /></div> 162. <div class="clear"></div></div> 163. <div class="clear"></div> 164. <p>How can we better serve you?<br /><textarea class="textareaService" name="better_service" cols="20" rows="20"></textarea><br /><br /> 165. <font size="-3">*Required fields</font></p> 166. <div class="fright" style="margin-top:11px;"><a href="feedback.html" onclick="document.getElementById('form1').reset()">Clear</a><img alt="" src="images/spacer.gif" width="16" height="1" /><a href="submit.php" onclick="document.getElementById('form1').submit()">Submit</a></div> 167. <div class="clear"> 168. </div> 169. </div></form> 170. 171. </div> 172. <img alt="" src="images/spacer.gif" width="9" height="1" /> 173. </div> 174. </div> 175. <div class="clear"><br style="line-height:18px;" /> 176. </div> 177. </div> 178. <!-- footer --> 179. <div id="footer"> 180. <div class="indent"> 181. T & B Electric Co. Inc• © 2008 • <a href="sitemap.html">Privacy Policy</a><br /> 182. Crofton, MD • Phone: (301) 261-3701 • Fax: (301) 261-3608 • In case of emergency: (301) 261-0755 </div> 183. </div> 184. </div> 185. </div> 186. </div> 187. </div> 188. <!-- Start of StatCounter Code --> 189. <script type="text/javascript"> 190. sc_project=3694554; 191. sc_invisible=1; 192. sc_partition=44; 193. sc_security="81b14c34"; 194. </script> 195. 196. <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a href="http://www.statcounter.com/" target="_blank"><img class="statcounter" src="http://c45.statcounter.com/3694554/0/81b14c34/1/" alt="web hit counter" ></a></div></noscript> 197. <!-- End of StatCounter Code --> 198. </body> 199. </html> The code for the html form is the following: 1. 2. <?xml version="1.0" encoding="utf-8"?> 3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5. <head> 6. <title>T & B Electric Co. Inc.</title> 7. <link href="style.css" rel="stylesheet" type="text/css" /> 8. <link href="layout.css" rel="stylesheet" type="text/css" /> 9. <script src="maxheight.js" type="text/javascript"></script> 10. <meta name="keywords" content="T & B Electric Co, electrical contractors, electricians, electrical services, Crofton, Maryland, celular communications, 11. electrical instalation, cellular site, electrical building maintenance, thermal imaging, technical consulting, electrical distribution relocation, electical 12. wiring, emergency electrical service, licensed electricians, NECA, National Electrical Contractors Association, State Master Electrical, east coast, commercial, 13. telecommunications, grounding protection services, electrical market, telecommunications carriers, electrical equipment, 24 x 7 emergency service, power 14. emergency service, power emergency, power company, electrical failure, power outages" /> 15. <meta name="decription" content="T&B Electric Co is a medium sized electrical contractor located in Crofton , MD , licensed to serve the east coast. The company services 16. include commercial, electrical services and cell communications, including safety programs, green sustainable technology, full electrical services, 24 x 7 emergency 17. services, electrical installation in cellular sites. T&B Electric Co. 301-261-0755." /> 18. </head> 19. 20. <body id="page5" onload="new ElementMaxHeight();"> 21. <div id="site_center"> 22. <div class="tall_top"> 23. <div class="tall_bottom"> 24. <div id="main"> 25. <!-- header --> 26. <div id="header"> 27. <div class="row_1"> 28. <div class="fleft"> 29. <h1><img src="images/logo_TB.gif" alt="" width="143" height="75" /></h1> 30. </div> 31. <div class="fright"> 32. <div class="indent"> 33. <div class="header_but"> 34. <div class="left"> 35. <div class="right"> 36. <div class="ind"> 37. <a class="link1" href="sitemap.html">Sitemap</a> <!-- :: <a class="link1" href="#">Login</a>--> 38. </div> 39. </div> 40. </div> 41. </div> 42. </div> 43. </div> 44. <div class="clear"></div> 45. </div> 46. <div class="row_2"> 47. <div class="indent"> 48. <a href="index.html">Home</a><img alt="" src="images/spacer.gif" width="64" height="1" /><a href="aboutus.html">About Us</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="licenses.html">Licenses</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="services.html">Services</a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="customerservices.html">Customer Service </a><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="feedback.html">Feedback</a><!--<img alt="" src="images/spacer.gif" width="64" height="1"/><a href="index-6.html">FAQ</a>--><img alt="" src="images/spacer.gif" width="64" height="1"/><a href="contactus.html">Contact Us</a><br /> 49. </div> 50. </div> 51. <div class="row_3"> 52. <div class="indent"> <br /> 53. </div> 54. </div> 55. </div> 56. <!-- content --> 57. <div><br style="line-height:18px;" /> 58. </div> 59. <div id="content"> 60. <div class="col_1 maxheight"> 61. <div class="indent"> 62. <h2><img alt="" src="images/5_t1.gif" /></h2> 63. <div class="indent1"> 64. <p class="title">Feedback</p> 65. <h3>We want to hear from you.</h3> 66. <p> T&B Electric Co has as business strengths the quality of service its personnel provides its clients for maintaining equipment and facilities in highly standard operating condition due to systematic inspection, detection, and correction of incipient failures either before they occur or before they develop into major defects. Our maintenance programs include tests, measurements, adjustments, and parts replacement, performed specifically to prevent faults from occurring. </p> 67. <p> If you are our client or had any service provided by T & B Electric Co., we want to hear from you. Send us your feedback on the service experience you had. We will be glad to hear from you. </p> 68. 69. 70. <img src="images/kitchen.jpg" alt="" width="249" height="187" class="img_indent" /> 71. <div class="clear"></div> 72. 73. </div> 74. </div> 75. </div> 76. <div class="col_2 maxheight"> 77. <div class="indent"> 78. <h2><img alt="" src="images/5_t2.gif" /></h2> 79. <div class="indent1"> 80. <h2 class="red">Send us your feedback.</h2> 81. <form id="form1" action="submit.php" method="post"> 82. <div class="container"> 83. <div class="column1"> 84. Date: <br/> 85. Name *: 86. <div class="form"><input type="text" name="name" /></div> 87. PO #: 88. <div class="form"><input type="text" name="po" /></div> 89. E-mail address*: 90. <div class="form"><input type="text" name="email" /></div> 91. <h3>Work Address.</h3> 92. Street: 93. <div class="form"><input type="text" name="work" /></div> 94. State: 95. <div class="form"><input type="text" name="state" /></div> 96. Response time*: 97. <div><input class="radio" type="radio" value="excellent" name="response_time"/>Excellent<br /> 98. <input class="radio" type="radio" value="good" name="response_time"/>Good<br /> 99. <input class="radio" type="radio" value="fair" name="response_time"/>Fair<br /> 100. <input class="radio" type="radio" value="need_improvement" name="response_time"/>Need Improvement<br /> 101. </div> 102. </div> 103. <div class="column2" style="float:right;"> 104. Time: <br /> 105. Phone*: 106. <div class="form"><input type="text" /></div> 107. Fax: 108. <div class="form"><input type="text" /></div> 109. Cell: 110. <div class="form"><input type="text" /></div> 111. <br /> 112. City: 113. <div class="form"><input type="text" /></div> 114. Zip: 115. <div class="form"><input type="text" /></div> 116. Work performed efficiently*: 117. <div><input class="radio" type="radio" value="yes_efficient" name="work_performed"/>Yes<br /> 118. <input class="radio" type="radio" value="no_efficient" name="work_performed"/>No<br /> 119. </div> 120. Was site left clean and safe? 121. * 122. <div><input class="radio" type="radio" value="yes_clean" name="clean_safe"/>Yes<br /> 123. <input class="radio" type="radio" value="no_clean" name="clean_safe"/>No<br /> 124. </div> 125. <div class="clear"></div> 126. </div> 127. <div class="clear"> 128. </div> 129. <p>How can we better serve you?<br /> 130. <textarea class=" textareaService" name="better_service" cols="20" rows="20"></textarea><br /> 131. <br /> 132. <font size="-3">*Required fields</font> 133. </p> 134. <div class="fright" style="margin-top:11px;"><a href="feedback.html" onclick="document.getElementById('form1').reset()">Clear</a><img alt="" src="images/spacer.gif" width="16" height="1" /><a href="submit.php" onclick="document.getElementById('form1').submit()">Submit</a></div> 135. <div class="clear"></div> 136. </div> 137. </form> 138. 139. </div> 140. <img alt="" src="images/spacer.gif" width="9" height="1" /> 141. </div> 142. </div> 143. <div class="clear"><br style="line-height:18px;" /> 144. </div> 145. </div> 146. <!-- footer --> 147. <div id="footer"> 148. <div class="indent"> 149. T & B Electric Co. Inc• © 2008 • <a href="sitemap.html">Privacy Policy</a><br /> 150. Crofton, MD • Phone: (301) 261-3701 • Fax: (301) 261-3608 • In case of emergency: (301) 261-0755 </div> 151. </div> 152. </div> 153. </div> 154. </div> 155. </div> 156. <!-- Start of StatCounter Code --> 157. <script type="text/javascript"> 158. sc_project=3694554; 159. sc_invisible=1; 160. sc_partition=44; 161. sc_security="81b14c34"; 162. </script> 163. 164. <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a href="http://www.statcounter.com/" target="_blank"><img class="statcounter" src="http://c45.statcounter.com/3694554/0/81b14c34/1/" alt="web hit counter" ></a></div></noscript> 165. <!-- End of StatCounter Code --> 166. </body> 167. </html> I understand that this might be something extremely basic... ??? but I just want to solve this so that the email with the form information is sent...the I will go celebrate! Any advice or suggestion to help me out will be greatly appreciated. :roll: :roll: Cheers, Beta Quote Link to comment https://forums.phpfreaks.com/topic/110213-newbie-php-form-with-a-mail-function-error/ Share on other sites More sharing options...
.josh Posted June 14, 2008 Share Posted June 14, 2008 bad params...did you echo out the variables you're trying to pass to mail() to see if they are holding what you expect? Quote Link to comment https://forums.phpfreaks.com/topic/110213-newbie-php-form-with-a-mail-function-error/#findComment-565548 Share on other sites More sharing options...
betabr2005 Posted June 14, 2008 Author Share Posted June 14, 2008 Crayon, Thank you for the hint. My variables are not being passed from the form to the submit.php page... I guess my problem shifted a little bit: values are not being passed. Beta Quote Link to comment https://forums.phpfreaks.com/topic/110213-newbie-php-form-with-a-mail-function-error/#findComment-565657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.