mail() & Blank Form Fields
Posted: Thu Oct 09, 2003 8:07 am
Hi.
This form:
http://cgi.southeringtons.plus.com/php/form.htm
Submits to this script:
http://cgi.southeringtons.plus.com/php/sendmail.txt
Please take a look at the code, particulary 'sendmail.txt'. A glance at the form web page will be useful aswell.
It's the mail() part of the script that I need help with. Here's a snippet of my code:
I want the text such as "Address1:", "Address2:" etc... to display only if there is actually something in the variables "$Address1", "$Address2" etc...
I know I could omit the "Address1:" text and just have the contents of the variables displayed, but I'll still end up with a blank line there if the textbox wasn't filled in. The idea behind this is to reduce the number of pages the email prints out on as it is unlikly that anyone will ever fill in all the form fields.
I hope I've explained this well enough. Let me know if you need more info.
-UserFriendly
This form:
http://cgi.southeringtons.plus.com/php/form.htm
Submits to this script:
http://cgi.southeringtons.plus.com/php/sendmail.txt
Please take a look at the code, particulary 'sendmail.txt'. A glance at the form web page will be useful aswell.
It's the mail() part of the script that I need help with. Here's a snippet of my code:
Code: Select all
mail("richard@southeringtons.co.uk",
"Southeringtons Web Enquiry",
"
Name: $Title $FirstName $LastName
E-Mail Address: $email
Address1: $Address1
Address2: $Address2
Address3: $Address3
Address4: $Address4
Address5: $Address5
Address6: $Address6
Address7: $Address7
...snipped lots more code (see url above for the rest)...
OA_Office: $OA_Office
OA_Loft: $OA_Loft
OA_Garage: $OA_Garage
OA_Garden: $OA_Garden
OA_AnywhereElse: $OA_AnywhereElse",
"From: $FirstName $LastName <$email>" );
header( "Location: http://cgi.southeringtons.plus.com/php/form.htm" );
?>I know I could omit the "Address1:" text and just have the contents of the variables displayed, but I'll still end up with a blank line there if the textbox wasn't filled in. The idea behind this is to reduce the number of pages the email prints out on as it is unlikly that anyone will ever fill in all the form fields.
I hope I've explained this well enough. Let me know if you need more info.
-UserFriendly