PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
foreach($_POST as $key => $value) {
//Do your validation for each input here, for example check if the field is empty or not
if(strlen(trim($value)) == 0) {
//Field is empty
}
}
Inside the loop you $key is the fieldname and $value is the value in that field.
echo 'The fields '.implode(', ', array_keys(array_diff_assoc($_POST, array_filter(array_map('trim', $_POST))))).' are empty!';
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.