我有一个mysqli登录脚本在这里工作正常:
if (isset($_POST['loginSubmit'])) {
$loginCheck = $mysqli->prepare('SELECT cms_user, cms_email FROM cms_accounts WHERE cms_email=? AND cms_password=?');
$loginCheck->bind_param('ss',$_POST['loginEmail'],sha1($_POST['loginPass']));
$loginCheck->execute();
$loginCheck->store_result();
if ($loginCheck->num_rows > 0) {
$_SESSION['loggedIn'] = '1';
}
else { $loginFail = true; }
$loginCheck->close();
}
现在我想将查询中选择的数据添加到其他会话变量中。所以我像这样添加bind_result()
和fetch()
:
if (isset($_POST['loginSubmit'])) {
$loginCheck = $mysqli->prepare('SELECT cms_user, cms_email FROM cms_accounts WHERE cms_email=? AND cms_password=?');
$loginCheck->bind_param('ss',$_POST['loginEmail'],sha1($_POST['loginPass']));
$loginCheck->execute();
$loginCheck->bind_result($loginUser,$loginEmail);
$loginCheck->fetch();
$loginCheck->store_result();
if ($loginCheck->num_rows > 0) {
$_SESSION['loggedIn'] = '1';
$_SESSION['loginUser'] = $loginUser;
$_SESSION['loginEmail'] = $loginEmail;
}
else { $loginFail = true; }
$loginCheck->close();
}
突然登录失败。是否可以在同一个查询中包含store_result()
和bind_result()
?是否有命令将它们写入?