Not much. PHP database query and user information verification.

Source: Internet
Author: User
Not much! PHP database query, user information verification first, on the code & lt ;? Php $ username = $ _ POST ["name"]; $ password = $ _ POST ["password"]; if ($ username & amp; $ pass is missing! PHP database query and user information verification
First, go to the code
$ Username = $ _ POST ["name"];
$ Password = $ _ POST ["password"];
If ($ username & $ password)
{
If (strpos ($ username ,"")! = False) echo "invalid user name ";
Else
{
$ Con = mysql_connect ("localhost", "root", "1 ");
Mysql_select_db ("manage", $ con );
$ SQL ="
Select *
From user
Where username = '$ username' and password =' $ password'
";
$ Query = mysql_query ($ SQL) or die (mysql_error ());
$ Row = mysql_num_rows ($ query );
/*
Var_dump ($ SQL );
Exit;
*/

If ($ row = 1) echo 'logon successful ';
Else
Echo 'logon failed ';
}
}
?>
I don't know why, my $ row obtained after execution is 0, but I use the obtained $ SQL

After Execution in the database, you can clearly query a record, so it is clear that there is a problem with the function after SQL query, but since I have no books, please advise. Share The PHP database MySQL:
------ Solution --------------------
Character encoding is not correct. try mysql_query (set names utf8 ).
------ Solution --------------------
What is the database encoding? add mysql_query ("set names utf8") before the query.
------ Solution --------------------
Such as mysql_query ("set names utf8"); this processing is missing and you should not make such low-level errors.

------ Solution --------------------
Character encoding not supported, mysql_query (set names utf8)

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.