Home > Backend Development > PHP Tutorial > PHP implements basic authentication

PHP implements basic authentication

WBOY
Release: 2016-07-29 08:56:42
Original
1125 people have browsed it

PHP implements basic authentication


<code><span><?php</span><span>if</span> (!<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>]))
{
    header(<span>'HTTP/1.1 401 Unauthorized'</span>);
    header(<span>'WWW-Authenticate: basic realm="Input username and password"'</span>);

    <span>exit</span>;
} <span>else</span> {
    <span>echo</span><span>'Your name is '</span> . <span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>];
    <span>echo</span><span>'<br>'</span>;
    <span>echo</span><span>'Your password is'</span> . <span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>];
}</code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the implementation of basic authentication in PHP, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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