Home>Article>Backend Development> How to verify login in http database in PHP

How to verify login in http database in PHP

不言
不言 Original
2018-07-19 16:08:47 3447browse

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 !"; } }

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登录验证"

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!

Statement:
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