Posted on : 2019-08-21 21:58:49 View Type: public
Simon So

Hi, i need the php files to process the contacts and appointment forms.
Hi, i need the php files to process the contacts and appointment forms.
As you have bought the HTML template which does not provide PHP to process forms. But i can guide you how you can make the forms working before that i need to confirm do you know the basics of php and html? If yes let me know.
We also have Dermatology WordPress theme which you can buy only in 25$ in case you want to use WordPress thanks.
Usually all HTML template that we have purchased comes with a another separation send.php / mail.php (phpmailer enable) , smtp settings etc.
We just want to save time so what we dont have to rebuild the forms. Kindly advise the necessary.
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
$mail_to = '[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.
Brilliant! That's exactly what we need.
Thank you
On first line please replace $mail_to = '[email protected]'; //Replace with your Email
with $mailto = '[email protected]'; //Replace with your Email
$mailto = Noted! Thank you again.