exit()停止后續(xù)腳本執(zhí)行
單個(gè)字段空白判定
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";