Loading...
PHP

WWW- Authentication

By using this header we can display Authentication dialog box on browser, every browser contains authentication dialog box by using this header we can display the dialog box

Basic Realm: By using this property we can display some text on authentication dialog box, authentication dialog box is providing username and password text box to validate the user account details.
<?php
header(“www-Authenticate: basic realm= mysite”);
?>

$_SERVER[‘PHP_AUTH_USER’]: By using this Super Global variable we can get some username text box value.

$_SERVER[‘PHP_AUTH_PW’]: By using this Super Global variable we get password text box value.
<?php
header(“www_Authenticate: Basic realm= mysite”);
echo $_SERVER[‘PHP_AUTH_USER’];
echo $_SERVER[‘PHP_AUTH_PW’];
?>

content_type: By using this header we can specify the type of content what we are transferring between the browser and server. Here telling the MIME tag to the browser regarding the data what we are sending.
<?php
header(“content_type: image/jpeg”);
echo file_get_contents(“sunset.jpg”);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *