1)appointment.html section
- <section id="service-single-area">
- <div class="container">
- <div class="row">
- <div class="col-lg-9 col-md-8 col-sm-12 col-xs-12 pull-right">
- <div class="service-single-content">
- <div class="appoinment-form">
- <div class="title">
- <h2>Make an Appoinmenth2>
- div>
- <form id="appoinmentone" name="appointment" action="sendmail.php" method="post" enctype="text/plain" >
- <div class="row">
- <div class="col-md-6">
- <input type="text" name="name" value="" placeholder="Your Name*"
- required="" id="name">
- <input type="email" name="email" value="" placeholder="Your Mail*"
- required="" id="email">
- <input type="text" name="phn" value="" placeholder="Phone Number*"
- required="" id="phone">
- <input type="date" name="date" value="" placeholder="Apointment Date*"
- required="" id="date">
- div>
- <div class="col-md-6">
- <select class="selectmenu" >
- <option selected="selected" id="prod" name="services">Select Serviceoption>
- <option id="prod">Commercial Aquaguardoption>
- <option id="prod">Industrial RO Plantsoption>
- <option id="prod">Water Cooleroption>
- <option >Commercial Vacuum Cleaneroption>
- <option>Water Ionizersoption>
- select>
- <textarea name="message" placeholder="Your Message.."
- required="" id="messsage">textarea>
- div>
- div>
- <div class="row">
- <div class="col-md-12">
- <form method="post">
- <button class="thm-btn bg-1" type="submit" onclick="document.getElementById('appoinmentone').submit();">Submit Nowbutton>
- form>
- div>
- div>
- form>
- div>
- div>
- div>
- div>
- div>
- 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.
- if (isset($_POST['email']))
- {
- // EDIT THE 2 LINES BELOW AS REQUIRED
- $email_to = "[email protected]";
- $email_subject = "Booking Received";
- function died($error)
- {
- // your error code can go here
- echo "We are very sorry, but there were error(s) found with the form you submitted. ";
- echo "These errors appear below.
"; - echo $error . "
"; - echo "Please go back and fix these errors.
"; - die();
- }
- // validation expected data exists
- if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments']))
- {
- died('We are sorry, but there appears to be a problem with the form you submitted.');
- }
- $name = $_POST['name']; // required
- $email_from = $_POST['email']; // required
- $telephone = $_POST['telephone']; // not required
- $comments = $_POST['comments']; // required
- $checkin = $_POST['SelectedDate1']; // required
- $checkout = $_POST['SelectedDate2']; // required
- $Place = $_POST['Place']; // required
- $error_message = "";
- $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
- if (!preg_match($email_exp, $email_from))
- {
- $error_message .= 'The Email Address you entered does not appear to be valid.
'; - }
- $string_exp = "/^[A-Za-z .'-]+$/";
- if (!preg_match($string_exp, $name))
- {
- $error_message .= 'The First Name you entered does not appear to be valid.
'; - }
- if (strlen($comments) < 2)
- {
- $error_message .= 'The Comments you entered do not appear to be valid.
'; - }
- if (strlen($error_message) > 0)
- {
- died($error_message);
- }
- $email_message = "Form details below.\n\n";
- function clean_string($string)
- {
- $bad = array(
- "content-type",
- "bcc:",
- "to:",
- "cc:",
- "href"
- );
- return str_replace($bad, "", $string);
- }
- $email_message .= "First Name: " . clean_string($name) . "\n";
- $email_message .= "Email: " . clean_string($email_from) . "\n";
- $email_message .= "Telephone: " . clean_string($telephone) . "\n";
- $email_message .= "Comments: " . clean_string($comments) . "\n";
- $body = "Mail Send";
- $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'];
- mail($email_to, $email_subject, $msg);
- echo 'Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.';
- ?>
- }
- ?>
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
Rajeesh MenothPosted Feb 14, 2020, 12:47 AM