除了插入数据stmt之外,一切似乎都可以正常工作。
我添加了关闭连接并添加了关闭语句。
$error = $user = $pass = "";
if (isset($_SESSION['user'])) destroySession();
if (isset($_POST['user']))
{
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if ($user == "" || $pass == "")
$error = 'Not all fields were entered<br><br>';
else
{
$stmt = $connection->prepare('SELECT * FROM members WHERE user=?');
$stmt->bind_param('s', $user);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows)
$error = 'That username already exists<br><br>';
else
{
$hashedPwd = password_hash($pass, PASSWORD_DEFAULT);
$stmt = $connection->prepare("INSERT INTO members (user, pass) VALUES (?,?)");
$stmt->bind_param("ss", $user, $hashedPwd);
$stmt->execute;
$stmt->close();
die('<h4>Account created</h4>Please Log in.</div></body></html>');
}
}
}
$connection->close();
我希望代码可以识别用户是否存在。但是,我不能期望用新用户来更新数据库。
答案 0 :(得分:0)
在页面顶部放置return self.command(self.display, self.colour, self.x, self.y, self.width, self.height)
将显示$ stmt-> execute存在问题;
$ stmt->执行;应该是error_reporting(E_ALL);