I put a request to see what was missing when I tried to do a simple calculator. The one bit of code that had to do with gathering the data from the html file:
$variable = $_POST["variable"];...has taken me pretty far in the book... however, noow that the book is getting a bit deeper... I am starting to get a bit lost. Here is a simple All-In-One email form that is supposed to print errors if the fields aren't filled in and it is also supposed to send... without going to another php script outside of this file. Here is the code.. I know it must be missing something!
If any body could help nudge me along again so I can get through another couple of chapters.. that would be great!
Thanks
<HTML>
<HEAD>
<TITLE>All-In-One Feedback Form</TITLE>
</HEAD>
<BODY>
<?
$form_block = "
<FORM METHOD=\"post\" ACTION=\"$PHP_SELF\">
<P><strong>Your Name:</strong><br>
<INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=30></p>
<P><strong>Your E-Mail Address:</strong><br>
<INPUT type=\"text\" NAME=\"sender_email\" VALUE=\"$sender_email\" SIZE=30></p>
<P><strong>Message:</strong><br>
<TEXTAREA NAME=\"message\" COLS=30 ROWS=5 WRAP=virtual>$message</TEXTAREA></p>
<INPUT type=\"hidden\" name=\"op\" value=\"ds\">
<P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send This Form\"></p>
</FORM>
";
if ($op != "ds") {
// they need to see the form
echo "$form_block";
} else if ($op == "ds") {
if ($sender_name == "") {
$name_err = "<font color=red>Please enter your name!</font><br>";
$send = "no";
}
if ($sender_email == "") {
$email_err = "<font color=red>Please enter your e-mail address!</font><br>";
$send = "no";
}
if ($message == "") {
$message_err = "<font color=red>Please enter a message!</font><br>";
$send = "no";
}
if ($send != "no") {
// it's ok to send!
$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .= "Sender's Name: $sender_name\n";
$msg .= "Sender's E-Mail: $sender_email\n";
$msg .= "Message: $message\n\n";
$to = "myemail@email.com";
$subject = "All-in-One Web Site Feedback";
$mailheaders = "From: My Web Site <> \n";
$mailheaders .= "Reply-To: $sender_email\n\n";
mail($to, $subject, $msg, $mailheaders);
echo "<P>Mail has been sent!</p>";
} else if ($send == "no") {
echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";
}
}
?>
</BODY>
</HTML>

New Topic/Question
Reply



MultiQuote




|