I've been stuck for a while now. This code works for the most part, however there is a small issue. When I request a username that doesn't exist in my table, the script fails at $stmt->fetch()
. It looks bad on the website when the script can't return an actual "invalid username/password" message and instead basically dies.
if($stmt = $DB_CON -> prepare("SELECT `ID`, `Username`, `Password`, `Email`, `Access`, `Banned` FROM `users` WHERE `Username`=?")) {
if(!($stmt -> bind_param('s', $USERNAME))){
die($stmt->error); //These return empty...
}
if(!($stmt -> execute())){
die($stmt->error);
}
if(!($stmt -> store_result())){
die($stmt->error);
}
if(!($stmt -> bind_result($ID, $USERNAME, $DB_PASSWORD, $EMAIL, $ACCESS, $BANNED))){
die($stmt->error);
}
if(!($stmt -> fetch())){
die($stmt->error);
}
What am I missing/need to change?
感谢@Rasclatt,解决方案是仅从脚本中删除if(!( ... ))
部分,因为它在无法返回信息时被杀死。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.