有人提交用户注册表格时会发生此错误
警告:/public_html/register.php在第55行遇到的非数字值
注意:第55行的/public_html/register.php中遇到的格式不正确的数值
这是第55行的代码
/* If there are no errors continue the registering process */
if(empty($_SESSION['error'])) {
/* Define some needed variables */
$password = User::encrypt_password($_POST['username'], $_POST['password']);
$active = ($settings->email_confirmation == 0) ? "1" : "0";
$email_code = md5($_POST['email'] + microtime());
$date = new DateTime();
$date = $date->format('Y-m-d H:i:s');
/* Add the user to the database */
$stmt = $database->prepare("INSERT INTO `users` (`username`, `password`, `email`, `email_activation_code`, `name`, `active`, `ip`, `date`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssss', $_POST['username'], $password, $_POST['email'], $email_code, $_POST['name'], $active, $_SERVER['REMOTE_ADDR'], $date);
$stmt->execute();
$stmt->close();
/* If active = 1 then login the user, else send the user an activation email */
if($active == "1") {
$_SESSION['user_id'] = User::login($_POST['username'], $password);
redirect("status/loggedin");
} else {
$_SESSION['success'][] = $language->register->success_message->registration;
sendmail($_POST['email'], $settings->contact_email, $language->register->email->title, sprintf($language->register->email->content, $settings->url, $_POST['email'], $email_code));
//printf($language->register->email->content, $settings->url, $_POST['email'], $email_code);
}
}
编辑
尝试过
$email_code = md5($_POST['email'] . microtime());
并使用点号串联解决了我在评论中发现的问题。