Here is an example of a simple feedback form using an HTML form page and a PHP page to process and mail the information gathered from the HTML fom:
Code:
<HTML>
<HEAD>
<title>Simple Feedback Form</title>
</HEAD>
<BODY>
<FORM METHOD = "POST" ACTION="feedbackform.php"
<p><strong>Your Name:</strong><br>
<INPUT type="text" NAME="sender_name" SIZE=30></p>
<p><strong>Your E-Mail Address:</strong<br>
<INPUT type="text" NAME="sender_email" SIZE ="30" </p>
<p><strong>Message:</strong><br>
<TEXTAREA NAME="message" COLS=40 ROWS=5 WRAP=virtual></TEXTAREA></p>
<p>INPUT TYPE="submit" NAME="submit" VALUE="Send This Form"></p>
</FORM>
</BODY>
</HTML>
This page should be named "simple_form.html"
Where it says ACTION="" This is where you name the PHP page that will process this form. In this case it's "feedbackform.php"
Everywhere it says NAME="" you can name this whatever you want to. These become the variables that are processed by the PHP form page.
Here is an example of the PHP page that will send the form information to your email.
Code:
<?
if (($_POST[sender_name] == "" ||
($_POST[sender_email] == "" ||
($_POST[message] == "" )) {
header("Location: simple_form.html");
exit;
}
$msg ="Sender's Name:\t$_POST[sender_name]\n";
$msg .= "Sender's E-Mail:\t$_POST[sender_email]\n";
$msg .= "Message:\t$_POST[message]\n";
$to = "you@yourdomain.com";
$subject = "Feedback Form";
$mailheaders = "From: My Web Site <feedback@yourdomain.com>\n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n"
mail ($to, $subject, $msg, $mailheaders);
?>
This page should be named "feedbackform.php"
You can see that the $_POST[] == "" is simply the variables we named in the simple_form.html page. These can be named anything as long as they are the same on both your HTML and PHP pages.
The $msg .="" is the message body of the email you will receive.
The $to ="" is where you want the email sent to.
The $subject ="" whatever you want the subject of your feedback emails to be.
The $mailheaders ="" These variables just add more headers to your email.
The mail () is the command to mail your variable fields to your email.
That should do it!
Hope this helps you!
Last edited by CobraHosts; 03-05-2006 at 03:02 PM..
|