Using an SMTP Server:
A Simple Feedback Form:
Creating the Feedback Form:
<HTML>
<HEAD>
<TITLE>Simple Feedback Form</TITLE>
</HEAD>
<BODY>
<FORM METHOD=”POST” ACTION=”send_simpleform.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=30 ROWS=5 WRAP=virtual></TEXTAREA></P>
<P><INPUT TYPE=”submit” NAME=”submit” VALUE=”Send This Form”></P>
</FORM>
</BODY>
</HTML>
Save the file with the name simple_form.html, and place this file in the document root of your Web server.
Creating a Script to Mail Your Form:
<?
if (($_POST[sender_name] == “”) ||
($_POST[sender_email] == “”) ||
($_POST[message] == “”)) {
header(“Location: simple_form.html”);
exit;
}
$msg = “E-MAIL SENT FROM WWW SITEn”;
$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 = “[email protected]”;
$subject = “Web Site Feedback”;
$mailheaders = “From: My Web Site <[email protected]>n”;
$mailheaders .= “Reply-To: $_POST[sender_email]n”;
mail($to, $subject, $msg, $mailheaders);
?>
<HTML>
<HEAD>
<TITLE>Simple Feedback Form Sent</TITLE>
</HEAD>
<BODY>
<H1>The following e-mail has been sent:</H1>
<P><strong>Your Name:</strong><br>
<? echo “$_POST[sender_name]”; ?>
<P><strong>Your E-Mail Address:</strong><br>
<? echo “$_POST[sender_email]”; ?>
<P><strong>Message:</strong><br>
<? echo “$_POST[message]”; ?>
</BODY>
</HTML>
Save the file with the name send_simpleform.php and place this file in the document root of your Web server.