vinoth.thy Posted September 8, 2007 Share Posted September 8, 2007 HI JUst i am trying to assign authentication for my web page by using the code <?php if ($PHP_AUTH_USER != “XXX” or $PHP_AUTH_PW != “XXX”): header("WWW-Authenticate: " . "Basic realm=\"Protected Page: " . "Enter your username and password " . "for access.\""); header("HTTP/1.0 401 Unauthorized"); ?> <HTML> <HEAD><TITLE>Authorization Failed</TITLE></HEAD> <BODY> <H1>Authorization Failed</H1> <P>Without a valid username and password, access to this page cannot be granted. Please click ‘reload’ and enter a username and password when prompted. </P> </BODY> </HTML> <?php else : header("Location:http://localhost/"); endif; ?> By using this code it always ask me the username and password just i entered the correct details since it ask me for authentication. Any body tell me how to use it. Link to comment https://forums.phpfreaks.com/topic/68455-how-to-set-usernamepassword-authentication-for-webpage/ Share on other sites More sharing options...
watthehell Posted September 8, 2007 Share Posted September 8, 2007 <?php if ($PHP_AUTH_USER != “XXX” or $PHP_AUTH_PW != “XXX”) { header("WWW-Authenticate: " . "Basic realm=\"Protected Page: " . "Enter your username and password " . "for access.\""); header("HTTP/1.0 401 Unauthorized"); ?> <HTML> <HEAD><TITLE>Authorization Failed</TITLE></HEAD> <BODY> <H1>Authorization Failed</H1> <P>Without a valid username and password, access to this page cannot be granted. Please click ‘reload’ and enter a username and password when prompted. </P> </BODY> </HTML> <? } else { header("Location:http://localhost/"); } ?> try this hope it works Link to comment https://forums.phpfreaks.com/topic/68455-how-to-set-usernamepassword-authentication-for-webpage/#findComment-344177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.