Re: Web page authentications

From: Date: Tue, 28 Aug 2001 06:00:07 +0000
Subject: Re: Web page authentications
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64732@lists.php.net to get a copy of this message
Hello Admin, The following example will help you HTTP Authentication example <?php if(!isset($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\n"; exit; } else { echo "<p>Hello $PHP_AUTH_USER.</p>"; echo "<p>You entered $PHP_AUTH_PW as your password.</p>"; } ?> 888888888888888888888888888888888888888888888888888888888888 HTTP Authentication example forcing a new name/password <?php function authenticate() { header( "WWW-Authenticate: Basic realm=\"Test Authentication System\""); header( "HTTP/1.0 401 Unauthorized"); echo "You must enter a valid login ID and password to access this resource\n"; exit; } if(!isset($PHP_AUTH_USER) || ($SeenBefore == 1 && !strcmp($OldAuth, $PHP_AUTH_USER)) ) { authenticate(); } else { echo "</p>Welcome: $PHP_AUTH_USER<br>"; echo "Old: $OldAuth"; echo "<form action=\"$PHP_SELF\" METHOD=POST>\n"; echo "<input type=\"hidden\" name=\"SeenBefore\" value=\"1\">\n"; echo "<input type=\"hidden\" name=\"OldAuth\" value=\"$PHP_AUTH_USER\">\n"; echo "<input type=\"submit\" value=\"Re Authenticate\">\n"; echo "</form></p>\n"; } ?> Thanks, Senthilvellan ----- Original Message ----- From: admin <admin@my-pcdoctor4u.com> To: <php-general@lists.php.net> Sent: Tuesday, August 14, 2001 11:52 PM Subject: [PHP] Web page authentications > I am new to PHP and am confused on HTTP authentications. I have read that > section in the manual and still have questions. Where does PHP look to see > if the user is valid or if the passward matches the user. How do you use > PHP to set up user registration so users can input their information for > authentication. Can anyone point me in the right direction to read more on > this and help clear my confusion. > Pat > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#64732) next »