(Help) check if the user name fails in the database. first, I want to check whether the user name is in the database! Apmserv is built in a local environment and has a bbs database and a meassage table. The table has three fields: id user pass, and the corresponding values are 1 admin; the types are int (10) varchar (25) varchar (25), and there are three local php files:
Conn. php
$ Conn = @ mysql_connect ("localhost", "root", "") or die ("database link error ");
Mysql_select_db ("bbs", $ conn );
Mysql_query ("set names 'utf-8'"); // use UTF-8 Chinese encoding;
?>
Register. php
Login. php
Include ("conn. php ");
If ($ _ POST ["submit"])
$ Name = $ _ POST ['user'];
$ SQL = "select * from message where user = '". $ name ."'";
$ Result = mysql_query ($ SQL) or die ("incorrect account ");
$ Num = mysql_num_rows ($ result );
If ($ num = 0 ){
Echo "account already exists ";
}
?>
Question: no matter what I input in register. php and submit it to login. php, the account already exists, and the original login. php file shows that the account already exists! I wanted to check whether the user name is in the database, but I felt that the database could not be called !!! What's wrong !!
Reply to discussion (solution)
// Form is a get submission.
The following is received using post, and will never enter if.
If ($ _ POST ["submit"])
$ Name = $ _ POST ['user'];
As stated in #1
Mysql_query ("set names 'utf-8'"); // use UTF-8 Chinese encoding;
= "Changed to 'utf8'
Why do you want to receive a submit?
If ($ _ POST ["submit"])
$ Name = $ _ POST ['user'];
Change to $ name = $ _ GET ['user'];
Add echo $ name;
As stated in #1
Mysql_query ("set names 'utf-8'"); // use UTF-8 Chinese encoding;
= "Changed to 'utf8'
Why do you want to receive a submit?
If ($ _ POST ["submit"])
$ Name = $ _ POST ['user'];
Change to $ name = $ _ GET ['user'];
Add echo $ name;
Thank you!