Nikita

Nikita

  • NA
  • 56
  • 10.1k

i want to sendemail php code for the following html section

Feb 12 2020 2:23 AM
1)appointment.html section
  1. <section id="service-single-area">  
  2. <div class="container">  
  3. <div class="row">  
  4. <div class="col-lg-9 col-md-8 col-sm-12 col-xs-12 pull-right">  
  5. <div class="service-single-content">  
  6. <div class="appoinment-form">  
  7. <div class="title">  
  8. <h2>Make an Appoinment</h2>  
  9. </div>  
  10. <form id="appoinmentone" name="appointment" action="sendmail.php" method="post" enctype="text/plain" >  
  11. <div class="row">  
  12. <div class="col-md-6">  
  13. <input type="text" name="name" value="" placeholder="Your Name*"  
  14. required="" id="name">  
  15. <input type="email" name="email" value="" placeholder="Your Mail*"  
  16. required="" id="email">  
  17. <input type="text" name="phn" value="" placeholder="Phone Number*"  
  18. required="" id="phone">  
  19. <input type="date" name="date" value="" placeholder="Apointment Date*"  
  20. required="" id="date">  
  21.   
  22. </div>  
  23. <div class="col-md-6">  
  24. <select class="selectmenu" >  
  25. <option selected="selected" id="prod" name="services">Select Service</option>  
  26. <option id="prod">Commercial Aquaguard</option>  
  27. <option id="prod">Industrial RO Plants</option>  
  28. <option id="prod">Water Cooler</option>  
  29. <option >Commercial Vacuum Cleaner</option>  
  30. <option>Water Ionizers</option>  
  31. </select>  
  32. <textarea name="message" placeholder="Your Message.."  
  33. required="" id="messsage"></textarea>  
  34. </div>  
  35. </div>  
  36. <div class="row">  
  37. <div class="col-md-12">  
  38. <form method="post">  
  39. <button class="thm-btn bg-1" type="submit" onclick="document.getElementById('appoinmentone').submit();">Submit Now</button>  
  40. </form>  
  41. </div>  
  42. </div>  
  43. </form>  
  44. </div>  
  45.   
  46. </div>  
  47. </div>  
  48. </div>  
  49. </div>  
  50. </section>  
2)here the refer php code for sending mail this is not for that appointment section its only for example purpose. i want to build same php code for that particular html section that i have given.
  1. <?php  
  2. if (isset($_POST['email']))  
  3. {  
  4. // EDIT THE 2 LINES BELOW AS REQUIRED  
  5. $email_to = "[email protected]";  
  6. $email_subject = "Booking Received";  
  7. function died($error)  
  8. {  
  9. // your error code can go here  
  10. echo "We are very sorry, but there were error(s) found with the form you submitted. ";  
  11. echo "These errors appear below.<br /><br />";  
  12. echo $error . "<br /><br />";  
  13. echo "Please go back and fix these errors.<br /><br />";  
  14. die();  
  15. }  
  16. // validation expected data exists  
  17. if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments']))  
  18. {  
  19. died('We are sorry, but there appears to be a problem with the form you submitted.');  
  20. }  
  21. $name = $_POST['name']; // required  
  22. $email_from = $_POST['email']; // required  
  23. $telephone = $_POST['telephone']; // not required  
  24. $comments = $_POST['comments']; // required  
  25. $checkin = $_POST['SelectedDate1']; // required  
  26. $checkout = $_POST['SelectedDate2']; // required  
  27. $Place = $_POST['Place']; // required  
  28. $error_message = "";  
  29. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';  
  30. if (!preg_match($email_exp$email_from))  
  31. {  
  32. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';  
  33. }  
  34. $string_exp = "/^[A-Za-z .'-]+$/";  
  35. if (!preg_match($string_exp$name))  
  36. {  
  37. $error_message .= 'The First Name you entered does not appear to be valid.<br />';  
  38. }  
  39. if (strlen($comments) < 2)  
  40. {  
  41. $error_message .= 'The Comments you entered do not appear to be valid.<br />';  
  42. }  
  43. if (strlen($error_message) > 0)  
  44. {  
  45. died($error_message);  
  46. }  
  47. $email_message = "Form details below.\n\n";  
  48. function clean_string($string)  
  49. {  
  50. $bad = array(  
  51. "content-type",  
  52. "bcc:",  
  53. "to:",  
  54. "cc:",  
  55. "href"  
  56. );  
  57. return str_replace($bad""$string);  
  58. }  
  59. $email_message .= "First Name: " . clean_string($name) . "\n";  
  60. $email_message .= "Email: " . clean_string($email_from) . "\n";  
  61. $email_message .= "Telephone: " . clean_string($telephone) . "\n";  
  62. $email_message .= "Comments: " . clean_string($comments) . "\n";  
  63. $body = "Mail Send";  
  64. $msg = 'Name:-' . $_POST['name'] . "\n" . 'Email:-' . $_POST['email'] . "\n" . 'Contact No:-' . $_POST['telephone'] . "\n" . 'Check In:-' . $_POST['SelectedDate1'] . "\n" . 'Check Out:-' . $_POST['SelectedDate2'] . "\n" . 'Place:-' . $_POST['Place'] . "\n" . 'cOMMENTS:-' . $_POST['comments'];  
  65. mail($email_to$email_subject$msg);  
  66. echo '<span style="color:#FFFFFF">Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.</span>';  
  67. ?>  
  68. <!-- include your own success html here  
  69. if($send_email)  
  70. {  
  71. echo "Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.";  
  72. }  
  73. else  
  74. {  
  75. echo "E-mail sent was failed !";  
  76. } -->  
  77. <?php  
  78. }  
  79. ?>  
pls suggest me. the php code for that with a specific email format the fields are name, mobile, address, date, services, message etc. it displays into the email

Answers (1)