我有这两个函数用于创建用户。第一个函数用于插入/创建用户和其他函数用于检查用户是否/存在于MySql
数据库中。但是当我发送数据时,我看到 die() 的空白页;(如果用户存在或用户不存在)如何解决这个错误?以及如何在红色框中打印错误列表,即:
- this user not activate
- email is empty
- ....
我的课:
public function createUser($email, $password, $salt, $verification) {
if($this->checkUserFound($email) != true ){die();}
$query = "INSERT INTO tbUsers (email, password, user_salt, is_verified, is_active, is_admin, verification_code) "
. "VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt = $this->_db->prepare($query);
$ver = 0;
$act = 1;
$adm = 0;
$stmt->bind_param("sssiiis", $email, $password, $salt, $ver, $act, $adm, $verification);
if ($stmt->execute()) {
return true;
}
return false;
}
public function checkUserFound($email) {
$query = "SELECT email FROM tbUsers where email = ?";
$stmt = $this->_db->prepare($query);
$stmt->bind_param("s", $email);
if ($stmt->execute()) {
$stmt->bind_result($email);
//fetch first row of results
$stmt->fetch();
return false;
}
return true;
}