Forum Moderators: coopster

Message Too Old, No Replies

Want to not send blank form fields

         

briesm

7:27 pm on Jun 3, 2005 (gmt 0)

10+ Year Member



Here is the relevant code to my mailing script portion. It still sends blank form fields though, anyone know how to correct this?

$message = "";

while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

$message = stripslashes($message);

mail($my_email,$subject,$message);

timster

8:00 pm on Jun 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you're adding to the $message string *outside* of your test if it's empty. Try this (warning untested):


while(list($key,$value) = each($_POST)) {
if (!(empty($value))) {
$set=1;
$message = $message . "$key: $value\n\n";
}
}