php mail() function?
1)appointment.html
- <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 Appoinment</h2>
- </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="" >
- <input type="email" name="email" value="" placeholder="Your Mail*"
- required="" >
- <input type="text" name="mobile" value="" placeholder="Phone Number*"
- required="" >
- <input type="date" name="date" value="" placeholder="Apointment Date*"
- required="">
-
- </div>
- <div class="col-md-6">
- <select class="selectmenu" name="service[]" multiple="multiple">
- <option selected="selected">Select Service</option>
- <option>Commercial Aquaguard</option>
- <option>Industrial RO Plants</option>
- <option>Water Cooler</option>
- <option>Commercial Vacuum Cleaner</option>
- <option>Water Ionizers</option>
- </select>
- <textarea name="message" placeholder="Your Message.."
- required="" ></textarea>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12">
- <form method="post" >
- <a href="#" class="contact-btn" onclick="document.getElementById('appoinmentone').submit()">Send</a>
- </form>
- </div>
- </div>
- </form>
- </div>
-
- </div>
- </div>
- </div>
- </div>
- </section>
2)sendmail.php
- <?php
- if (isset($_POST['email']))
- {
-
- $email_to = "[email protected]";
- $email_subject = "Appointment Received";
- function died($error)
- {
-
- echo "We are very sorry, but there were error(s) found with the form you submitted. ";
- echo "These errors appear below.<br /><br />";
- echo $error . "<br /><br />";
- echo "Please go back and fix these errors.<br /><br />";
- die();
- }
-
- if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['mobile']) || !isset($_POST['date'])|| !isset($_POST['service'])|| !isset($_POST['message']))
- {
- died('We are sorry, but there appears to be a problem with the form you submitted.');
- }
- $name = $_POST['name'];
- $email_from = $_POST['email'];
- $mobile = $_POST['mobile'];
- $date = $_POST['date'];
- $service = $_POST['service'];
- $message = $_POST['message'];
- $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.<br />';
- }
- $string_exp = "/^[A-Za-z .'-]+$/";
- if (!preg_match($string_exp, $name))
- {
- $error_message .= 'The First Name you entered does not appear to be valid.<br />';
- }
- if (strlen($mobile) < 11)
- {
- $error_message .= 'The mobile number you entered do not appear to be valid.<br />';
- }
- 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 .= "Mobile: " . clean_string($mobile) . "\n";
- $email_message .= "Date: " . clean_string($date) . "\n";
- $email_message .= "Services: " . clean_string($service) . "\n";
- $email_message .= "Message: " . clean_string($message) . "\n";
- $body = "Mail Send";
- $msg = 'Name:-' . $_POST['name'] . "\n" . 'Email:-' . $_POST['email'] . "\n" . 'Mobile:-' . $_POST['mobile'] . "\n" . 'Date:-' . $_POST['date'] . "\n" . 'Services:-' . $_POST['service'] . "\n" . 'Message:-' . $_POST['message'];
- mail($email_to, $email_subject, $msg);
-
- if($send_mail)
- {
- echo "Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.";
- }
- else
- {
- echo "E-mail sent was failed !";
- }
- ?>
- <!--include your own success html here-->
-
- <?php
- }
- ?>
please suggest me the solution for above problem. here i want to pass date and selected values to email along with other details