Form fails with empty email field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • GreatGretsky
    Corporal

    • Mar 2007
    • 12

    Form fails with empty email field

    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
    Major General

    • Sep 2005
    • 2116

    #2
    Re: Form fails with empty email field

    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

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment

    • navaldesign
      General & Forum Moderator

      • Oct 2005
      • 12080

      #3
      Re: Form fails with empty email field

      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);
      ?>
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment

      • GreatGretsky
        Corporal

        • Mar 2007
        • 12

        #4
        Re: Form fails with empty email field

        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.

        Comment

        Working...
        X