exit()停止后续脚本执行
单个字段空白判定
if(empty($_POST['last_name']))
{
echo "You did not enter your last name.
Last name is required.<br />\n";
redisplay the form;
exit();
}
echo "Welcome to the Members Only club.
You may select from the menu below.\n";
display the menu;
所有字段空白判定
foreach($_POST as $value)
{
if($value == "")
{
echo "You have not filled in all the fields.\n";
redisplay the form;
exit();
}
}
echo "Welcome";
除之外都空白判定
foreach($_POST as $field => $value)
{
if($value == "")
{
if($field != "fax" and $field != "middle_name")
{
echo "You have not filled in $field\n";
display the form;
exit();
}
}
}
echo "Welcome";