Hope I'm not hijacking here....
The script I'm trying to write is producing the same error:
Notice: Undefined variable: email_err in c:\program...yadda yadda
I understand that supressing the errors can prevent this, but as I am so new to PHP/and programing in general, wouldn't I need to code this correctly as to not trigger the error in the first place?
My script is running Mostly OK... but the "error handling" written in is where I'm having the most issues.
The script is set to trigger if there is no info entered into the text box. It does trigger, but also gives me the "Undefined variable" Notice.
Suppressing the error with the @ prior to the variable is not working.
Any help would be MOST appreciated!
Code:
<HEAD>
<TITLE>All-In-One Form</TITLE>
</HEAD>
<BODY>
<?
//Form Creation
$form_block = "
<FORM METHOD=\"POST\" ACTION=\"$_SERVER[PHP_SELF]\">
<P><strong>Your Name:</strong><br>
<INPUT type=\"text\" NAME=\"sender_name\" SIZE=30></p>
<P><strong>Your E-mail:</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>
<INPUT type=\"hidden\" name=\"op\" value=\"ds\">
<P><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send\"></P>
</FORM>";
//Check to see if they've seen the form-else show it.
if (@$POST[op] != "ds") {
echo "$form_block";
} else if (@$POST[op] == "ds") {
//Did they enter their name?
if (@$POST[sender_name] == "") {
$name_err = "<fonr color=RED>Please enter your name!</font><br>";
$send = "no";
}
//Did they enter their e-mail?
if (@$POST[sender_email] == "") {
$email_err = "<fonr color=RED>Please enter your e-mail!</font><br>";
$send = "no";
}
//Did they enter a message?
if (@$POST[message] == "") {
$message_err = "<fonr color=RED>Please enter a message!</font><br>";
$send = "no";
}
if (@$send != "no") {
//Ok to send!
$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .= "Sender's Name: $POST[sender_name]\n";
$msg .= "Sender's E-mail: $POST[sender_email]\n";
$msg .= "Sender's Message: $POST[message]\n\n";
$to = "miked@hobbieshawaii.com";
$subject = "Example Feedback Form";
$mailheaders = "From: My Site <> \n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n\n";
//Send the mail.
mail($to, $subject, $msg, $mailheaders);
//Let 'em know it went.
echo "<p>Mail has been sent!</p>";
}else if ($send == "no") {
//Show error messages
echo "$name_err"; //This is where PHP is spitting the Notice at me.
echo "$email_err"; //This is where PHP is spitting the Notice at me.
echo "$message_err"; //This is where PHP is spitting the Notice at me.
echo "$form_block";
}
}
?>
</BODY>
</HTML>
Mahalo!