I have a login interface. If the user name does not exist when entering the user name, a registration prompt is prompted, but it is clear that I may not know the SQL statement, so there is always a problem, even if you enter a user name that does not exist in the database during debugging, no prompt is displayed. if (! Empty ($ _ POST [& #039; login & #039;]) {... I have a login interface. If the user name does not exist when entering the user name, a registration prompt is prompted, but it is clear that I may not know the SQL statement, so there is always a problem, even if you enter a user name that does not exist in the database during debugging, no prompt is displayed.
If (! Empty ($ _ POST ['login']) {
// If the user name does not exist, the system prompts $ isset_ SQL = "select username from user where username = '$ username'"; $ is_exist = mysql_query ($ isset_ SQL); if (! $ Is_exist) {echo "script" alert ('the current user does not exist. Please check or select to register! '); Window. location. href = 'Article. login. php' script "; exit ();}
$query = "select password from user where username='$username'";..............
Reply content:
I have a login interface. If the user name does not exist when entering the user name, a registration prompt is prompted, but it is clear that I may not know the SQL statement, so there is always a problem, even if you enter a user name that does not exist in the database during debugging, no prompt is displayed.
If (! Empty ($ _ POST ['login']) {
// If the user name does not exist, the system prompts $ isset_ SQL = "select username from user where username = '$ username'"; $ is_exist = mysql_query ($ isset_ SQL); if (! $ Is_exist) {echo "script" alert ('the current user does not exist. Please check or select to register! '); Window. location. href = 'Article. login. php' script "; exit ();}
$query = "select password from user where username='$username'";..............
First, do not usemysql_*
A series of connection methods. ChangePDO
OrMySQLi
Then your answer:mysql_query
You only need to executemysql_fetch_assoc
To obtain the database response.
Warning:mysql_*
It has been officially removed by PHP.
// Connect to the Database Section $ db = new PDO ('mysql: host = localhost; dbname = database name', 'username', 'Password '); $ db-> exec ('set names utf8 '); // use preprocessing to solve the SQL injection vulnerability $ stmt = $ db-> prepare ('select username from user where username =: username '); // bind the parameter $ stmt-> bind (': username', $ username, PDO: PARAM_STR); // execute the query $ stmt-> execute (); // get data $ user = $ stmt-> fetchColumn (); echo $ user? 'Registered ': 'unregistered ';