if($row){ //判断密码是否正确 if($row['user_password']===$password){ echo 1; }else{ echo "密码错误"; }}else{ echo "没找到用户名"; }
The above code is used to verify that the user entered the user name and password is correct, in order to see I simplified the code to get rid of the contents of the database data, why when the page is opened after nothing to lose will be output "no user found"?
Reply content:
if($row){ //判断密码是否正确 if($row['user_password']===$password){ echo 1; }else{ echo "密码错误"; }}else{ echo "没找到用户名"; }
The above code is used to verify that the user entered the user name and password is correct, in order to see I simplified the code to get rid of the contents of the database data, why when the page is opened after nothing to lose will be output "no user found"?
if ($row) this piece of code needs to be written in the post request code block. This code is not executed until the get is done.
For example, after clicking the login, the submitted user and Password fields are: username password
$username = isset($_POST['username']) ? $_POST['username'] : false;$password = isset($_POST['password']) ? $_POST['password'] : false;if($username && $password){ if($row){ //判断密码是否正确 if($row['user_password']===$password){ echo 1; }else{ echo "密码错误"; } }else{ echo "没找到用户名"; }}
You print $row out to see what it is.
That means you execute the code when you open the page, and if it's false
Now that you haven't found the user and the description $row is fake, you should focus on getting $row the code, not the code you're looking at.