deemurphy Posted August 8, 2007 Share Posted August 8, 2007 I am building a web site and have included an admin area where I want to use a username and password that only myself and the admin will be able to use. I am using the following code, but something is wrong when I put it on my host: <?php $myusername = "myname"; $mypassword = "password"; $areaname = "User's Protected Area"; if ($_SERVER["PHP_AUTH_USER"] == "" || $_SERVER["PHP_AUTH_PW"] == "" || $_SERVER["PHP_AUTH_USER"] != $myusername || $_SERVER["PHP_AUTH_PW"] != $mypassword) { header("HTTP/1.0 401 Unauthorized"); header("WWW-Authenticate: Basic realm=\"$areaname\""); echo "<h1>Authorization Required.</h1>"; die(); } ?> Can anyone tell me what is wrong with this code? Thank you Dee Link to comment https://forums.phpfreaks.com/topic/63815-protected-areaadmin-area/ Share on other sites More sharing options...
teng84 Posted August 8, 2007 Share Posted August 8, 2007 tell us the error????????????? Link to comment https://forums.phpfreaks.com/topic/63815-protected-areaadmin-area/#findComment-318043 Share on other sites More sharing options...
deemurphy Posted August 8, 2007 Author Share Posted August 8, 2007 It does not give an error. On my server it works. On my hosting server it just keeps flashing to the login and password option. Dee Link to comment https://forums.phpfreaks.com/topic/63815-protected-areaadmin-area/#findComment-318048 Share on other sites More sharing options...
teng84 Posted August 8, 2007 Share Posted August 8, 2007 it works fine on me hmmmm maybe the server is the prob Link to comment https://forums.phpfreaks.com/topic/63815-protected-areaadmin-area/#findComment-318056 Share on other sites More sharing options...
deemurphy Posted August 8, 2007 Author Share Posted August 8, 2007 OK, thank you. I will check with them. Dee Link to comment https://forums.phpfreaks.com/topic/63815-protected-areaadmin-area/#findComment-318059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.