php - Check if multiple strings are empty -
possible duplicate:
more concise way check see if array contains numbers (integers)
php checking if empty fields
i have form submits 10 fields, , 7 of them should filled, here how chek 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 }
my question is: there more simple way this? because have more strings check (12-15)
<input type="text" name="required[first_name]" /> <input type="text" name="required[last_name]" /> ... $required = $_post['required']; foreach ($required $req) { $req = trim($req); if (empty($req)) echo 'gotcha!'; }
/* update */
ok! guys, easy...
you can make more secure, type casting programmers out coming data, $id = (int) $_get['id']
, $username = (string) addslashes($_post['username'])
, on...;
$required = (array) $_post['required'];
and then, ever comes post fields let them come, code seek need. it! uhh...
Comments
Post a Comment