Send HTML form as Rating/ Review/ Enquiry/ Contact Form in email using PHP script

by · January 8, 2013

When you are working on the permotion emails or newsletter one thing is very important i.e Contact Form/ Rating form/ Review form/ Html form in email beacuse now a days everyone got a number of permotion emails. No one has that much of time to copy your email address and compose a new email and send you a query. So the smart way to do this is send a HTML form in email having all of the nessary fields of your enquiry. So that if anybody have question/query regarding your business, He can directly send his query from the mail enquiry form.

For this I am dicussing here 2 possible ways:

1) Get the HTML e mail response on your email id.

2) Get the HTML e mail response on your Server.

1) Get the HTML e mail response on your email id:

When you send the email using this script and the recipient will submit the HTML form then the form submission is done through the email server used by recepient. You will get the email from the recepient’s email id. This is the quick process as compared to 2nd method.

<?php
$to = ‘myself@myemail.com’;

$subject = ‘HTML Form in Email’;

$headers = “From: myself@myemail.com\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;
$message = ‘<html><body>’;

$message .= ‘<form method=”post” action=”mailto:your@email.com?subject=Enquiry subject”>’;
$message .= ‘Name: <input type=”text” name=”Name” /><br/>’;
$message .= ‘Message: <input type=”textarea” name=”message”><br/>’;

$message .= ‘<br />’;
$message .= ‘<input type=”submit” value=”Submit” /></form>’;
$message .= ‘</body></html>’;

mail($to, $subject, $message, $headers);
?>

2) Get the HTML e mail response on your server:

<?php
$to = ‘myself@myemail.com’;

$subject = ‘HTML Form in Email’;

$headers = “From: myself@myemail.com\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;

$message = ‘<html><body>’;
$message .= ‘<form action=”http://yourssite.com/submitmail.php” method=”post” target=”_blank”>’;
$message .= ‘<h2>How did you like our post at<strong>knowAhead.in</strong>?</h2><br />’;
$message .= ‘<input name=”rate” value=”1″ type=”radio” /> 1<br />’;
$message .= ‘<input name=”rate” value=”2″ type=”radio” /> 2<br />’;
$message .= ‘<input name=”rate” value=”3″ type=”radio” /> 3<br />’;
$message .= ‘<input name=”rate” value=”4″ type=”radio” /> 4<br />’;
$message .= ‘<input name=”rate” value=”5″ type=”radio” /> 5<br />’;
$message .= ‘<br />’;
$message .= ‘<label for=”commentText”>Leave a review/experiance:</label><br />’;
$message .= ‘<textarea cols=”75″ name=”commentText” rows=”5″></textarea><br />’;
$message .= ‘<br />’;
$message .= ‘<input type=”submit” value=”Submit your review” /></form>’;
$message .= ‘</body></html>’;

mail($to, $subject, $message, $headers);
?>

This script will send the form to the mail of recepient and when the recepient submit this form. You will get the response on your PHP page http://yourssite.com/submitmail.php.

You will get the response by PHP variable
$_REQUEST[‘rate’]; is used to get the rating i.e 1,2,3,4,5.
$_REQUEST[‘commentText’]; is used to get reciepient’s review/experiance.

You can use these values according to you requirements like you may store these values to your database or send a mail to your’s email id.

VN:F [1.9.22_1171]
Rating: 7.6/10 (34 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 5 votes)
Send HTML form as Rating/ Review/ Enquiry/ Contact Form in email using PHP script, 7.6 out of 10 based on 34 ratings

You may also interested in: