Recently I want to add a simple username verification mechanism to the web page, because I have used Sina Cloud's http authorization verification method before, and it is naturally perfect for single web page verification.
In fact, the user verification method of http is very simple. Just judge the two values of $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']. Here is a simple example:
<code><span><span><?php</span><span>if</span> (!<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>])) { header(<span>'WWW-Authenticate: Basic realm="My Realm"'</span>); header(<span>'HTTP/1.0 401 Unauthorized'</span>); <span>echo</span><span>'Text to send if user hits Cancel button'</span>; <span>exit</span>; } <span>else</span> { <span>echo</span><span>"<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"</span>; <span>echo</span><span>"<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"</span>; } <span>?></span></span></code>
in the else of the above code Just check whether the username and password are the same as specified.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above has introduced Http authorization to implement simple web user password verification, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.