Consecutive if statements
Posted: Fri Sep 10, 2010 8:45 am
Hi,
I've just registered as I can't find the answer to what I think is a fairly mundane question through google (other search engines are available) - so first of all hello!
I'm looking at building an error message depending on whether certain fields have been included on submission of a form. In essence it goes like this -
I'm sure you can see what I'm trying to achieve - basically if it's true it appends the error message to the existing error message to echo them all when it includes the page to be displayed. Is this a legitimate approach to what I'm trying to achieve? If...else won't work as multiple if statements could be true...
Any help would be appreciated and please bear in mind I've not tested the above code - it's just off the top of my relatively nivoce head to illustrate the point.
Thanks for any help everyone.
MP
I've just registered as I can't find the answer to what I think is a fairly mundane question through google (other search engines are available) - so first of all hello!
I'm looking at building an error message depending on whether certain fields have been included on submission of a form. In essence it goes like this -
Code: Select all
if (!$_POST['signup_fname']) {
$displayError = $displayError.'Please enter your first name<br/>';
}
if (!$_POST['signup_lname']) {
$displayError = $displayError.'Please enter your last name<br/>';
}
if (!$_POST['signup_postcode']) {
$displayError = $displayError.'Please enter your postcode<br/>';
}
if (!$_POST['signup_mem_place']) {
$displayError = $displayError.'Please enter a memorable place<br/>';
}Any help would be appreciated and please bear in mind I've not tested the above code - it's just off the top of my relatively nivoce head to illustrate the point.
Thanks for any help everyone.
MP