Re: Just learning . . . HTML Form & PHP

From: Date: Tue, 27 Aug 2002 22:35:40 +0000
Subject: Re: Just learning . . . HTML Form & PHP
Groups: php.general 
Request: Send a blank email to php-general+get-114296@lists.php.net to get a copy of this message
>Next I'd just like to confirm that the fields are not blank and send a >custom error message. But I think I'm confused about where to place the >code. Where you currently have "if ($send != "no"){ ... }" you could tack on something like: else{ echo $name_err; echo $email_err; echo $lastname_err; } Once that works, as an improvement, it might make more sense to do like this: $message = ''; if ($name == ''){ $message .= "Name must be provided.<BR>\n"; } if ($email == ''){ $message .= "Email must be provided.<BR>\n"; } if ($lastname == ''){ $message .= "Last name must be provided.<BR>\n"; } if (!$message){ # Send the email. } else{ echo "<FONT COLOR=FF0000>$message</FONT>\n"; } By using $message and .= to "tack on" the messages, you can avoid having so many variables running around confusing you and get the job done just as well. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#114296) next »