PHP database query and password matching function

Source: Internet
Author: User
This article mainly introduces PHP database query and password matching function, interested in the friend's reference, I hope to help you.

This paper introduces a simple test landing class for PHP implementation, as follows:

<?phpclass checklogin{  var $name;  var $pwd;  function __construct ($username, $password)  {   $this->name= $username;   $this->pwd= $password;  }  function Checkinput ()  {   global $db;   $sql = "SELECT * from Tb_manager where name= ' $this->name ' and pwd= ' $this->pwd '";   $res = $db->query ($sql);   $info = $db->fetch_array ($res);    if ($info [' name ']== $this->name and $info [' pwd ']== $this->pwd)   {     $_session[admin_name]= $info [name];     $_session[pwd]= $info [pwd];     echo "<script>alert (' Login successful! ); window.location.href= ' index.php ';</script> ";   }   else   {     echo "<script language= ' JavaScript ' >alert (' Login failed! '); History.back ();</script> ";     Exit;}}}  ? >

Summary: The above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

PHP Digital and digital Operation verification Code

How to implement JSON code conversion in PHP

Implementation of multi-dimensional array traversal and unset deletion method in PHP

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.