php mail() function?
1)appointment.html
"service-single-area"> - class="container">class="row">class="col-lg-9 col-md-8 col-sm-12 col-xs-12 pull-right">class="service-single-content">class="appoinment-form">class="title">
Make an Appoinment
- name="appointment" action="sendmail.php" method="post" enctype="text/plain" >
class="row">class="col-md-6">- "text" name="name" value="" placeholder="Your Name*"
- required="" >
- "email" name="email" value="" placeholder="Your Mail*"
- required="" >
- "text" name="mobile" value="" placeholder="Phone Number*"
- required="" >
- "date" name="date" value="" placeholder="Apointment Date*"
- required="">
class="col-md-6">- ="selectmenu" name="service[]" multiple="multiple">
- >Select Service
- placeholder="Your Message.."
- required="" >
class="row">class="col-md-12">- >
- "#" class="contact-btn" onclick="document.getElementById('appoinmentone').submit()">Send
2)sendmail.php
- if (isset($_POST['email']))
- {
- // EDIT THE 2 LINES BELOW AS REQUIRED
- $email_to = "[email protected]";
- $email_subject = "Appointment 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['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']; // required
- $email_from = $_POST['email']; // required
- $mobile = $_POST['mobile']; // not required
- $date = $_POST['date']; // required
- $service = $_POST['service']; // required
- $message = $_POST['message']; // 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($mobile) < 11)
- {
- $error_message .= 'The mobile number 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 .= "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);
- // echo "Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.";
- 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 !";
- }
- ?>
- }
- ?>
please suggest me the solution for above problem. here i want to pass date and selected values to email along with other details
Replies
Know the answer? Post it — somebody with the same question will find it here.