還有這里轉義字符串,使用 mysqli_escape_string 會把 ' 轉移成為 \' 導致后面連接不成功, 我使用了 mysqli_real_escape_string 在前面只對 $username,$password 進行了轉移,并且在后面也對 index.php 中的 $userId 進行了處理,但是我不知道后面這個處理是否必要。
2018-05-26
我覺得 10:53 只要登錄了就要發 auth 憑證,同時在前面用三元運算符判斷是否設置 autoLogin 根據 autoLogin 的值是否為 1 ,用 setcookie(...,strtotime('+7 days')) 給予不同過期時間,這樣后面 20:33 的時候 auth 就不用改判斷。否則邏輯上有只要存在 $_COOKIE['username']就可以跳過判定的 bug 了,作為教學課程有 bug 也感覺不舒服。
2018-05-26
$sql="select id,username,password from user where username='{$username}' && password='{$password}'";
Error: check the manual that corresponds to your MySQL server version for the right syntax to use near '\'king\' && password=\'665525c23c8f84a27367d1c86bec4935\'' at line 1
求解
Error: check the manual that corresponds to your MySQL server version for the right syntax to use near '\'king\' && password=\'665525c23c8f84a27367d1c86bec4935\'' at line 1
求解
2018-04-22