Home > Backend Development > PHP Tutorial > PHP first certification

PHP first certification

WBOY
Release: 2016-07-29 09:02:51
Original
1148 people have browsed it

PHP first authentication

<code><span><span><?php</span><span>// User name and password for authentication</span><span>$username</span> = <span>'rock'</span>;
  <span>$password</span> = <span>'roll'</span>;

  <span>if</span> (!<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>]) || !<span>isset</span>(<span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>]) ||
    (<span>$_SERVER</span>[<span>'PHP_AUTH_USER'</span>] != <span>$username</span>) || (<span>$_SERVER</span>[<span>'PHP_AUTH_PW'</span>] != <span>$password</span>)) {
    <span>// The user name/password are incorrect so send the authentication headers</span>
    header(<span>'HTTP/1.1 401 Unauthorized'</span>);
    header(<span>'WWW-Authenticate: Basic realm="Guitar Wars"'</span>);
    <span>exit</span>(<span>'<h2>Guitar Wars</h2>Sorry, you must enter a valid user name and password to access this page.'</span>);
  }
<span>?></span></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 has introduced the first PHP certification, including aspects of the content. 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