Http Authorization for simple Web user password verification

Source: Internet
Author: User
Recently want to add a simple user name verification mechanism in the Web page, because previously used Sina cloud HTTP authorization authentication method, as a single page verification naturally more appropriate.
In fact, the HTTP user authentication method is very simple, by judging $_server[' Php_auth_user ') and $_server[' PHP_AUTH_PW '] two values to post a simple example:


    
     if (!isset($_SERVER['PHP_AUTH_USER'])) {    header('WWW-Authenticate: Basic realm="My Realm"');    header('HTTP/1.0 401 Unauthorized');    echo'Text to send if user hits Cancel button';    exit;} else {    echo"

Hello {$_SERVER['PHP_AUTH_USER']}.

"; echo"

You entered {$_SERVER['PHP_AUTH_PW']} as your password.

";}?>

In the else of the above code, determine if the user name and password are the same as specified.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the HTTP authorization implementation of a simple Web user password verification, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.