Posted by Unknown
On
Wednesday, 26 December 2012
The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version. In an Apache module PHP script, it is possible to use the header () function to send an "Authentication Required" message to the client browser causing it to pop up a Username/Password input window.
Once the user has filled in a username and a password, the URL containing the PHP script will be called again with the predefined variables PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPEset to the user name, password and authentication type respectively. These predefined variables are found in the $_SERVER and $HTTP_SERVER_VARS arrays. Both "Basic" and "Digest" (since PHP 5.1.0) authentication methods are supported. See the header () function for more information.download code
03 | if (( $_SERVER [ 'PHP_AUTH_USER' ] == "root" ) AND |
04 | ( $_SERVER [ 'PHP_AUTH_PW' ] == "password" )) |
06 | echo ( "successfully!<br>\n" ); |
12 | header( "WWW-Authenticate: " . |
13 | "Basic realm=\"Scriptime's Protected Area\"" ); |
15 | header( "HTTP/1.0 401 Unauthorized" ); |
19 | print( "This page is protected by HTTP " ); |
user name ="root"
password= "password"
out put
|
out put |
If you would like one then just put the following in your comment
0 comments:
Post a Comment