...

View Full Version : Leaving Fields Blank Help...



craighowarth
12-31-2006, 04:08 PM
Basically...

I have got...


if (empty($name))
{
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your name, please go back and fill your name in the required field.</span></div>';
include 'quote.htm';
}
elseif(empty($email))
{
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your email address, please go back and fill your email address in the required field.</span></div>';
include 'quote.htm';
}
elseif (empty($other))
{
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter any information about what you would like designing, please go back and fill in all the information possible in the required field.</span></div>';
include 'quote.htm';
exit();
}
else

And what i'd like to do is make them ALL come up if they are ALL left blank.. the way it is atm, only 1 of them comes up at a time.

For example, if 'name' and 'email' are left blank... only name will come up as an error message.

GJay
12-31-2006, 04:14 PM
you're not qutie clear about what should happen if 2 of the 3 are blank...I'll assume you want two error messages...
It's also not apparent what quote.htm contains, but I'll assume you only want that once, no matter how many error messages:
You've also got a dangling else at the end, but I assume that contains the code for 'no errors'...


$errors=false;
if (empty($name)) {
$errors=true;
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your name, please go back and fill your name in the required field.</span></div>';
}
if(empty($email))
{
$errors=true;
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter your email address, please go back and fill your email address in the required field.</span></div>';
}
if (empty($other))
{
$errors=true;
echo '<div align="center" <span class="style2"><strong>ERROR:</strong> You did not enter any information about what you would like designing, please go back and fill in all the information possible in the required field.</span></div>';
}
if($errors) {
include 'quote.htm';
exit();
}
else { //the exit makes this not entirely necessary...
//no errors
}

craighowarth
12-31-2006, 04:17 PM
You got it all right :D Sorry I wasn't overally clear, was typing it in a rush.

Thanks for your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum