HTML CONTACT FORM PROCESS


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. PART 1
  2. --------------------------------------------------
  3. <table width="60%" border="0" align="center" cellpadding="6" cellspacing="2">
  4. <tr>
  5. <td><div align="right">
  6. <label for="textfield">Name:</label>
  7. </div></td>
  8. <td><div align="left">
  9. <input name="name" type="text" id="Name" size="45" maxlength="100" />
  10. </div></td>
  11. </tr>
  12. <tr>
  13. <td><div align="right">
  14. <label for="label">Email:</label>
  15. </div></td>
  16. <td><div align="left">
  17. <label for="label"></label>
  18. <input name="email" type="text" id="Email" size="45" maxlength="100" />
  19. </div></td>
  20. </tr>
  21. <tr>
  22. <td><div align="right">
  23. <label for="label2">Message:</label>
  24. </div></td>
  25. <td><div align="left">
  26. <textarea name="message" cols="45" rows="5" id="Message"></textarea>
  27. </div></td>
  28. </tr>
  29. <tr>
  30. <td><div align="right">
  31. <label>
  32. <input name="clear" type="reset" id="clear" value="Clear All" />
  33. </label>
  34. </div></td>
  35. <td><div align="left">
  36. <label for="Submit"></label>
  37. <input name="send" type="submit" id="send" onclick="MM_validateForm('Name','','R');MM_validateForm('Email','','RisEmail');MM_validateForm('Message','','R');return document.MM_returnValue" value="Send!" />
  38. </div></td>
  39. </tr>
  40. </table>
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. PART 2
  48. ---------------------------------------------------------
  49. <?php
  50.  
  51. //setting variables
  52. $emailSubject = 'Contacted!';
  53. $webMaster = 'YOUREMAIL!';
  54. //gathering data variables
  55.  
  56. $email = $_POST['email'];
  57. $name = $_POST['name'];
  58. $message = $_POST['message'];
  59.  
  60. $body = <<<EOD
  61. <br><hr><br>
  62. Email: $email <br>
  63. Name: $name <br>
  64. Message: $message <br>
  65.  <br>
  66. EOD;
  67.  
  68. $headers = "From: $email
  69. ";
  70. $headers .= "Content-type: text/html
  71. ";
  72. $success = mail($webMaster, $emailSubject, $body, $headers);
  73.  
  74. //displaying results as HTML
  75.  
  76.  
  77. $results = <<<EOD
  78. <html>
  79. <head>
  80.  
  81. </head>
  82. <body>
  83. <hr/>
  84. <p><a href="index.html">Go Back</a></p>
  85. </body>
  86. <html>
  87. EOD;
  88. echo "$results";
  89. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.