我正在尝试使用php将表单数据发送到服务器,但是由于某些原因,我遇到了以下错误:
解析错误:语法错误,意外的''(T_ENCAPSED_AND_WHITESPACE),第108行上的标识符(T_STRING)或变量(T_VARIABLE)或(T_NUM_STRING)。
在localhost中,我的服务器可以与phpmyadmin一起正常工作,但是在webhost中,它会给出该错误。
function validate_user_registration(){
$errors = [];
$min = 3;
$max = 20;
$maxEmail = 40;
if($_SERVER['REQUEST_METHOD'] == "POST") {
$first_name = clean($_POST['first_name']);
$last_name = clean($_POST['last_name']);
$username = clean($_POST['username']);
$email = clean($_POST['email']);
$password = clean($_POST['password']);
$confirm_password = clean($_POST['confirm_password']);
if(strlen($first_name) < $min){
$errors[] = "Your first name cannot be less than {$min} characters";
}
if(strlen($first_name) > $max) {
$errors[] = "Your first name cannot be more than {$max} characters";
}
if(strlen($last_name) < $min) {
$errors[] = "Your last name cannot be less than {$max} characters";
}
if(strlen($last_name) > $max) {
$errors[] = "Your last name cannot be more than {$max} characters";
}
if(strlen($username) < $min) {
$errors[] = "Your username cannot be less than {$min} characters";
}
if(strlen($username) > $max) {
$errors[] = "Your username cannot be more than {$max} characters";
}
if(strlen($email) > $maxEmail) {
$errors[] = "Your email cannot be more than {$maxEmail} characters";
}
if($password !== $confirm_password) {
$errors[] = "Your password fields do not match";
}
if(email_exists($email)) {
$errors[] = "Sorry that email already is registered";
}
if(username_exists($username)) {
$errors[] = "Sorry that username is already taken";
}
if(!empty($errors)) {
foreach ($errors as $error) {
echo validation_errors($error);
}
} else {
if(register_user($first_name, $last_name, $username, $email, $password)){
set_message("<p class='bg-success text-center'>Please check your email or spam folder for activation link</p>");
redirect("index.php");
} else {
set_message("<p class='bg-danger text-center'>Sorry we could not register the user</p>");
redirect("index.php");
}
}
} // post request
} // function