Password Form

 


<?php 

	// File Name: auth01.php
	// Check to see if $PHP_AUTH_USER already contains info

	if (!isset($PHP_AUTH_USER)) {

		// If empty, send header causing dialog box to appear
		header('WWW-Authenticate: Basic realm="My Private Stuff"');
		header('HTTP/1.0 401 Unauthorized');
		echo 'Authorization Required.';
		exit;
	}

		// If not empty, display values for variables

	else {

		echo "
		<P>You have entered this username: $PHP_AUTH_USER<br>
		You have entered this password: $PHP_AUTH_PW<br>
		The authorization type is: $PHP_AUTH_TYPE</p>
		";

	}

?>





<?php 

	// File Name: auth02.php

	// Check to see if $PHP_AUTH_USER already contains info

	if (!isset($PHP_AUTH_USER)) {

		// If empty, send header causing dialog box to appear

		header('WWW-Authenticate: Basic realm="My Private Stuff"');
		header('HTTP/1.0 401 Unauthorized');
		echo 'Authorization Required.';
		exit;

	} else if (isset($PHP_AUTH_USER)) {

		if (($PHP_AUTH_USER != "admin") || ($PHP_AUTH_PW != "abc123")) {

			header('WWW-Authenticate: Basic realm="My Private Stuff"');
			header('HTTP/1.0 401 Unauthorized');
			echo 'Authorization Required.';
			exit;

		} else {
			echo "
			<P>You're authorized!</p>
			";
		}
	} 


?>