Discussion on user authentication of PHP (i.)

Source: Internet
Author: User
Discussion on user authentication of PHP (i.)
Popcorn September 25, 2001 Www.westxj.net
When browsing the Web site, we often encounter some Web pages will require the user and password verification,
This requires us to write the appropriate authentication program to implement this feature. Here are some of my learning process and experience, I hope to help you.
(i) Single-user authentication based on HTTP authentication:
We use the function header () to send HTTP headers to force validation, the client browser pop-up to enter the user name and Password dialog box, when the client's user input information, is transferred to the server after the $php_auth_user, $PHP _auth_ PW the two global variables. Using these variables, you can authenticate users and passwords.
The following program can perform simple authentication
?
if ($PHP _auth_user!= ' Jane ' | | $PHP _auth_pw!= ' 123456 ')
{
Header ("Www-authenticate:basic realm=\" "Popcorn landing \");
Header ("http/1.0 401 Unauthorized");
echo "Authentication Error! ";
Exit
}
?>
(Note: When using HTTP authentication, you must run it as an Apache module, and if you are using a CGI-mode PHP, you will not be able to implement HTTP based authentication.) )
----is adjourned-----


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.