What happened to this login module?

Source: Internet
Author: User
What happened to this login module? The database clearly has something that cannot be read. the source code is as follows: it always shows an account and password error. why ;? Php checks whether the user has logged on to session_start (); if (! Empty ($ _ SESSION [username]) {echo & quot; you have logged on to the page! & Quot; exit;} echo & what happened to this login module?
The database clearly has something that cannot be read. the source code is as follows: the account and password are always displayed incorrectly.
// Determine whether the user has logged on
Session_start ();
If (! Empty ($ _ SESSION ['username'])
{
Echo "you have logged on to the page! ";
Exit;
}
// Echo "Hello,". $ _ SESSION ['username'];
?>
Require_once ('check. php'); // introduce public files to check user input and prevent SQL injection vulnerability code
// The trim () function can intercept leading and trailing spaces
$ Username = trim ($ _ POST ['username']);
$ Pwd = md5 ($ _ POST ['pwd']);


// Set an error variable to check for errors
$ Errmsg = '';
If (empty ($ username) | empty ($ _ POST ['pwd'])
{
$ Errmsg = 'input data is incomplete ';

}
If (! Empty ($ username) & empty ($ errmsg ))
{


Include_once (conn. php );
If (! $ Conn)
{
$ Errmsg = "database connection error ";
}
// $ SQL = mysql_query ("select * from tb_yonghu ");
$ SQL = mysql_query ("select * from tb_yonghu where name = '$ username' and password =' $ pwd '");
$ Info = mysql_fetch_array ($ SQL );
$ Row = mysql_num_rows ($ SQL );
If (! $ Row ){
$ Errmsg = "incorrect account or password ";
}
Else {

// Use session to save the current user
Session_start ();
$ _ SESSION ['username'] = $ username;

// You can use the redirection function mentioned above to go to the home page
$ Errmsg = "logon successful! ";
// Update user login information
$ Ip = $ _ SERVER ['remote _ ADDR ']; // Obtain the client IP address
$ SQL = "update tb_yonghu set f_logintimes = f_logintimes + 1, f_lasttime = now (), f_loginip = '$ IP' where name =' $ username '";
Mysql_query ($ SQL );
}

// Close the database connection
Mysql_close ($ conn );
}

?>



User Login


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.