PDA

View Full Version : Form fails with empty email field



GreatGretsky
04-20-2007, 10:14 PM
I just discovered that my form fails when the user does not provide their e-mail address.

When the user fills in the e-mail field, the form is delivered to my e-mail fine. When the e-mail field is left blank, the form simply never shows up.

I discovered this quite by accident.

I've now given the field an initial value of Your_Email@Here.com, which appears to solve the problem, although it looks silly.

Is there any better solution??

The domain is nowsavecash.com

I'm using the following html in my action page:

<BODY bgcolor="#FFFFFF" text="#000000" <?PHP
$email = $HTTP_POST_VARS[email];
$mailto = "jwolff@altusmortgage.net";
$mailsubj = "Inquiry from NowSaveCash.com";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

Watdaflip
04-21-2007, 02:18 AM
Add

if($email == "")
$email = "default@default.com";
// Change default@default.com to whatever you want it doesn't matter

after

$email = $HTTP_POST_VARS[email];

hope that helps

navaldesign
04-21-2007, 06:27 AM
If there is no email address entered in the form, the email gets blocked by the ISP's antispam filters. So the solution Watadaflip suggested will solve the problem Furthermore, i would suggest that you use your own email address as the default sender's address, converting the script as followes:

<?PHP
$mailto = "jwolff@altusmortgage.net";
$email = $HTTP_POST_VARS[email];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Inquiry from NowSaveCash.com";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

GreatGretsky
04-22-2007, 12:51 AM
Thanks guys! Works like a charm!

I discovered this problem completely by accident. Makes me wonder how many others are not getting forms delivered when users skip entering their e-mail addresses.

Anyway, thanks for the quick reply.