Download email_processor.php file and place this file in root folder where you are keeping the HTML files.
After that please edit your HTML forms and if <form tag exists then change or add action="email_processor.php" and method="post" if form tag does not exist please wrap your form in <form tags </form and use action="email_processor.php" method="post" Below you can see how the form tag should look like.
<form action="email_processor.php" method="post">
Form fields
</form>
Now please create a hidden field with name contact_form and make its value YES , This is a simple check that email_processor.php file is not accessed directly.
<input type="hidden" name="contact_form" value="YES" />
Now use the fields you want and name them accordingly like name="first_name", name="last_name", name="doctor" so on.
Once submit button is clicked the form will be sent to email_processor.php which will catch the posted values including hidden contact_form value YES which email_processor.php will check and process the form. In email_processor.php make sure you change the names or include more names matching your HTML form names. Below is the view of email_process.php which handles two forms footer form and contact form.
<?php
$mailto = '[email protected]'; //Replace with your Email
//Contact Form Submission
if($_POST['contact_form'] == 'YES') {
$message = '<table><tr><td>';
$message .= 'Your Name</td><td>';
$message .= $_POST['your_name'];
$message .= '</td></tr><tr><td>Your Email</td><td>';
$message .= $_POST['your_email'];
$message .= '</td></tr>';
$message .= '<tr><td>Your Website</td><td>';
$message .= $_POST['your_website'];
$message .= '</td></tr>';
$message .= '<tr><td>Your Message</td><td>';
$message .= $_POST['your_message'];
$message .= '</td></tr>';
$message .= '</table>';
$subject = "Contact Form Submission";
send_email($message, $mailto, $subject);
HEADER("LOCATION: thankyou.html");
}
//Footer Form submission
if($_POST['form_submission'] == 'YES') {
$message = '<table><tr><td>';
$message .= 'Your Name</td><td>';
$message .= $_POST['your_name'];
$message .= '</td></tr><tr><td>Your Phone</td><td>';
$message .= $_POST['your_phone'];
$message .= '</td></tr></table>';
$subject = "Footer Email Submission";
send_email($message, $mailto, $subject);
HEADER("LOCATION: thankyou.html");
}
function send_email($message, $mailto, $subject) {
$from_email = "[email protected]";
$reply_to = "[email protected]";
$mailheaders = "From:".$from_email;
$mailheaders .="Reply-To:".$reply_to;
$from = $from_email;
$headers = "FROM: ".$from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$filename}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
mail($mailto, $subject, $message, $headers);
}// Send Email Function.
In above form don't forget to change email_from and reply_to inside the function. And don't forget to change email $mail_to at top where you want to receive emails. Reply to and email from should be related to your domain name to avoid emails going to spam.