Forum Moderators: coopster
So, please, can someone tell me what my error is in this code?
<?php
if ($ID == "")
{
$id_err = "<font color='red'>Please enter your ID Number.</font><br>";
$send = "no";
}
$Pattern = ".+@.+\..+";
if (!eregi($Pattern, $Email))
{
$email_err = "<font color=red>Your e-mail address appears to be invalid.</font><br>";
$send = "no";
}
if ($Name == "")
{
$name_err = "<font color=red>Please enter your name.</font><br>";
$send = "no";
}
if ($Bill_Address == "")
{
$billing_err = "<font color=red>Please enter your billing address.</font><br>";
$send = "no";
}
if ($City_State_Zip == "")
{
$city_err = "<font color=red>Please enter your City, State, and Zip.</font><br>";
$send = "no";
}
if ($Phone =="")
{
$phone_err = "<font color=red>Please enter your phone number.</font><br>";
$send = "no";
}
if ($send!= "no")
{
foreach($HTTP_POST_VARS as $key => $value)
{
$message .= $key . ": " . $value;
$message .= "\n";
mail("me@myaddress.net","Order Form","$message","From: $Name <$Email>");
header ("Location: thanks.php?Name=$Name");
}
}
elseif ($send == "no")
{
echo $id_err;
echo $email_err;
echo $name_err;
echo $billing_err;
echo $city_err;
echo $phone_err;
}
?>
The test form is here:
<snip>
Also, how would I validate the radio buttons with php?
Thanks for any assistance!
[edited by: jatar_k at 2:39 am (utc) on Aug. 5, 2003]
[edit reason] no urls thanks [/edit]
If you move the mail() and header() lines outside of the foreach loop, you should be alright.
foreach($HTTP_POST_VARS as $key => $value)
{
$message .= $key . ": " . $value;
$message .= "\n";
}
mail("me@myaddress.net","Order Form","$message","From: $Name <$Email>");
header ("Location: thanks.php?Name=$Name");
}