Forum Moderators: coopster
else
{
//do something
}
was wondering if the above code, which chceks for set and empty fields, can be done with a while loop. or any opther way for that matter? above code works fine, but just like to know my options...
k
$errorflag = 0;
$checkarray = array('name', 'email', 'message');
foreach($checkarray as $v){
if(empty($_POST[$v])) $errorflag = 1;
}
if($errorflag) {
echo 'Please fill in all fields';
} else {
/* do something else */
}
note: checking to see if $x is set and if it's empty is redundant. For this you can just check if it's empty.
(!isset($_POST['name']) ¦¦ empty($_POST['name']) ¦¦!isset($_POST['email']) ¦¦ empty($_POST['email']) ¦¦!isset($_POST['messege']) ¦¦ empty($_POST['messege']) )
a while look , first you need to make them variable second you need to use your brain like a mathematicians.
They Work hard
get the solution
calculate the complexity
(never think there is an alternative , never think is it needed , just prove thats possible)
AjiNIMC mathematician by mistake