Possible Duplicate:
More concise way to check to see if an array contains only numbers (integers)
PHP checking if empty fields
I have form that submits 10 fields, and 7 of them should be filled, here is how i chek it now in PHP:
if (!$name || !$phone || !$email || !$mobile || !$email || !$state || !$street || ! $city) {
echo '<div class="empty_p">You have empty fields!!!</div>';}
else{
//process order or do something
}
My question is: is there more simple way to do this? Because sometimes I have even more strings to check (12-15)
/* update */
OK! guys, easy…
You can make it more secure, just with type casting as all we programmers do for out coming data, like
$id = (int) $_GET['id'], like$username = (string) addslashes($_POST['username'])and so on…;$required = (array) $_POST['required'];And then, what ever comes from post fields let them come, this code just seek what it need.
That is it! Uhh…