Yesterday, JS was able to call. Today, it suddenly cannot be called. <;? Phpinclude (yanzhengma. php); require_once (common. php); & nbsp; introduce public files, which implement the SQL Injection Vulnerability Check Code $ username & nbsp; trim ($ _ POST [username]); yesterday, JavaScript can still be called. Today, it suddenly cannot be called.
// Include ('yanzhengma. php ');
// Require_once ('Common. php'); // introduces a public file, which implements the SQL Injection Vulnerability Check Code
$ Username = trim ($ _ POST ['username']);
// Echo $ username;
// Obtain the password submitted by the client and use the md5 () function for subsequent verification.
$ Pwd = md5 ($ _ POST ['pwd']);
// Set an error message variable to determine whether an error has occurred.
// And display the error message on the client. The initial value is null.
$ Errmsg = '';
If (! Empty ($ username) {// the user enters the data to perform database operations
//---------------------
// Data verification. the empty () function determines whether the variable content is empty.
If (empty ($ username )){
$ Errmsg = 'incomplete data input ';
}
//---------------------
If (empty ($ errmsg) {// $ if errmsg is null, the verification is successful.
// Call the mysqli constructor to establish a connection and select the database 'test'
$ Db = @ new mysqli ("localhost", "root", "", "test ");
// Check the database connection
If (mysqli_connect_errno ()){
$ Errmsg = "database connection failed! \ N ";
}
Else {
// Query the database to check whether the user name and password are correct
$ SQL = "SELECT * FROM t_user WHERE f_username = '$ username' AND f_password =' $ pwd '";
$ Rs = $ db-> query ($ SQL );
// $ Rs-> num_rows checks whether the preceding execution results contain records. if there are records, the logon is successful.
If ($ rs & $ rs-> num_rows> 0 ){
// You can use the redirection function mentioned above to go to the home page
$ Errmsg = "logon successful! ";
}
Else {
$ Errmsg = "the user name or password is incorrect. logon failed! ";
}
// Close the database connection
$ Db-> close ();
}
}
}
If ($ rs & $ rs-> num_rows> 0 ){
// Use session to save the current user
Session_start ();
$ _ SESSION ['uid'] = $ username;
// You can use the redirection function mentioned above to go to the home page