我的问题是:
<?php
function user_exists($username) {
$username = sanitize($username);
return (mysql_result(mysql_query("SELECT_COUNT('user_id') FROM `user` WHERE `username` = '$username'"), 0) == 1) ? true : false;
}
?>
如您所见,我已包含正确的数据库名称并且用户确实存在,这就是我调用它以从 sql 中提取的位置:
<?php
include 'core/init.php';
if (user_exists('dan') === true) {
echo 'exists';
}
die();
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username) === true || empty($password) === true {
$errors[] = 'You need to enter a username and password';
} else if (user_exists($username) === false) {
$errors[] = 'Sorry this user does not exist';
}
}
?>
我不知道为什么我得到一个空白页并且它显示的消息是说用户存在?