How to verify login in http database in PHP

不言
Release: 2023-04-03 09:24:01
Original
3381 people have browsed it

How to verify login in http database in PHP? Next, let’s take a look at an implementation example of http database authentication login in PHP.

1. About the file authentication method

Parse the login account and password stored in the created .htpasswd file

Extract the http sent from the front desk Verify the login account and password

$_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']

Compare the code and the database method respectively

Code address

https://github.com/956077081/PHP_demo/blob/master/HttpLogin.php

2. About file comparison based on database

prepare("select name ,passwd from auth where name=? and passwd=?");
   $stm->bind_param("ss",$user,$passwd);
   $stm->execute();
   $stm->store_result();
   if ( $stm->num_rows == 0 ){
       authenticate_user();
   }else{
       echo "you are sucessful to login !";
   }
}
Copy after login

Corresponding database (httpauth) The plain text verification method can also be used to encrypt and compare the database and PHP original data by yourself

use httpauth;
create table autht(
id int(10)  UNSIGNED not NULL  AUTO_INCREMENT,
name VARCHAR(50) NOT NULL  DEFAULT '' ,
passwd VARCHAR(50)  not NULL DEFAULT '',
harsh VARCHAR(50)  DEFAULT '',
PRIMARY KEY(id,name),
INDEX `asd` (name)
 ) ENGINE = INNODB , DEFAULT CHARSET = UTF8 COMMENT="HTTP登录验证"
Copy after login

Related recommendations:

php User cookie login verification and mysql data login verification methods

php uses curl to simulate logging into a website with a verification code, curl verification code

The above is the detailed content of How to verify login in http database in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!