Easy one this. You've
if (send!="no") { do all the send stuff}
where you should have
if ($send!="no") {do all the send stuff}
note the $ sign that tells PHP to reference the variable.
It should work now but I haven't looked very closely at it yet
Ross
Anthony Ritter wrote:
>
> I'm working through Julie Meloni's book PHP - Fast and Easy using MS Win 98
> with Apache.
>
> She has an example of a PHP script where both the html form for input and
> the php code to send the form are in one php script using the mail()
> function and the $PHP_SELF global variable.
>
> I've included the code taken form the book: allinone_form.php
> and
> the code that I copied from the book when I tried to breakdown and
> understand the syntax which is:
> allinone1211.php
>
> Both scripts are able to send e-mail. However, in her script if the user
> fails to put either their name or address or message in the boxes, they are
> reminded to fill in the box in red - in addition, the email is not sent.
>
> However, in the allinone1211.php - which was copied line for line (or so I
> thought) - the email is sent even if the user has not filled in all of the
> appropriate boxes without the red reminders.
>
> If anybody has a chance could they take a look a the following code:
>
> Thanking all in advance.
> Tony Ritter
> ........................................................
>
> (allinone_form.php) Works fine.
>
> <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") {
> 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") {
> $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 = "[EMAIL PROTECTED]";
> $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>
> .................................................................
>
> allinone1211.php (email is sent even if the boxes are not filled in)
>
> <HTML>
> <HEAD>
> <TITLE> All In One Script </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 email address:</STRONG><BR>
> <INPUT TYPE=\"text\" NAME=\"sender_email\" VALUE=\"$sender_email\"
> SIZE=30> </P>
> <P><STRONG>Your 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") {
> 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 email address! </font>
> <br>";
> $send="no";
> }
> if($message==""){
> $message_err="<font color=red> Please enter a message! </font><br>";
> $message="no";
> }
> if (send!="no"){
> $msg="This email is being sent from\n";
> $msg.="Sender's name: $sender_name\n";
> $msg.="Sender's email address: $sender_email\n";
> $msg.="Message: $message\n\n";
> $to="[EMAIL PROTECTED]";
> $subject="All in one";
> $mailheaders="From: My website<>\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>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]