当我在没有指定任何 POST 变量的情况下发布到这个脚本时,脚本应该会重定向,但仍然会说。当我把 die(); 在第一个 if 函数之后,页面实际上被重定向了。
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$school = $_POST['school'];
$grade = $_POST['grade'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$test=FALSE;
$required = array ('firstname','lastname','email','phone','gender','dob','school','grade','password','password2');
foreach ($required as $value)
{
if(!isset($_POST[$value]) || empty($_POST[$value]))
{
$test = TRUE;
}
}
if($test)
{
header("location:../register.php?error=1");
}
$id = getRand(9);
$conn = getConnection();
$check = saveUser($firstname,$lastname,$email,$phone,$gender,$dob,$school,$grade,$password,$id,$conn );
if($check)
{
header("location:../quiz.php");
}
else
{
header("location:../register.php");
}