dquigley
New Member
- Messages
- 249
- Reaction score
- 0
- Points
- 0
So I am reading a PHP book that gives me lessons and teaches me how to code it and I am currently trying to create a simple form that lets you enter your name email and a message and then that sends it to the email address. The problem is when i click the submit form it just seems to refresh the page, the data I input disappears, and the page stays the same, and I checked my email and it wasn't sent. However the coding is supposed to redirect to a page saying your email was sent blah, anyways here is the code, please tell me the typo I made, I would like to keep the coding the same, as this is the way the book is teaching me, I am sure I just made a simple error.
Heres the HTML Form Page
And Here Is The PHP Part
Heres the HTML Form Page
<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_name" 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>
And Here Is The PHP Part
PHP:
<?
if (($_POST[sender_name] == "") ||
($_POST[sender_email] == "") ||
($_POST[message] == "")) {
header("Location: simple_form.html");
exit;
}
$msg = "E-MAIL SENT FROM WWW SITE\n";
$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 = "dquigley@dollarstoriches.com";
$subject = "Web Site Feedback";
$mailheaders = "From: My Web Site <dquigley@dollarstoriches.com>\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>