web form - don't send if line isn't filled out

Discussing Html . Code , Software , other

Moderators: egami, macek, gesf

Post Reply
element121
php-forum Fan User
php-forum Fan User
Posts: 606
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Tue Dec 08, 2015 10:22 am

You can probably add an if statement around each block:

Code: Select all

if isset($line1qty)
{
    // Line 1 Email Information
   $email_message .= "Line 1\n";
    $email_message .= "Quantity: ".$line1qty."\n";
   $email_message .= "Part Number: ".$line1pn."\n";
   $email_message .= "Manufacturer: ".$line1mfg."\n";
   $email_message .= "Description: ".$line1descr."\n\n";
   }

element121
php-forum Fan User
php-forum Fan User
Posts: 606
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Tue Dec 08, 2015 1:48 pm

You would have to do the same for line 2...

Code: Select all

if (isset($line2qty))
{
    // Line 2 Email Information.......
   }

element121
php-forum Fan User
php-forum Fan User
Posts: 606
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Tue Dec 08, 2015 3:47 pm

I can't see the html of your form, but instead of isset you could try

Code: Select all

if (strlen($line2qty) > 0)
{....
}

Post Reply