A small PHP question about logon

Source: Internet
Author: User
{Code ...} the above code is used to verify whether the user name and password entered by the user are correct. for convenience, I simplified the code and removed the content for obtaining database data, why does the output & quot; fail to find the user & quot; after opening the page?
If ($ row) {// Determine whether the password is correct if ($ row ['User _ password'] ===$ password) {echo 1 ;} else {echo "incorrect password" ;}} else {echo "no user name found ";}

The above code is used to verify whether the user name and password entered by the user are correct. for convenience, I simplified the code and removed the content for obtaining database data, why does "no user found" output when nothing is lost after the page is opened?

Reply content:
If ($ row) {// Determine whether the password is correct if ($ row ['User _ password'] ===$ password) {echo 1 ;} else {echo "incorrect password" ;}} else {echo "no user name found ";}

The above code is used to verify whether the user name and password entered by the user are correct. for convenience, I simplified the code and removed the content for obtaining database data, why does "no user found" output when nothing is lost after the page is opened?

If ($ row) code must be written in the POST request code block. In this way, the code will not be executed.

For example, after clicking 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) {// Determine whether the password is correct if ($ row ['User _ password'] ===$ password) {echo 1 ;}else {echo "incorrect password ";}} else {echo "user name not found ";}}

You print $ row to see what it is.

It indicates that the code is executed when you open the webpage, and if it is false

Note:$rowIf it is false, you should focus on obtaining$rowInstead of focusing on the posted code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.