Jump to content

Protected area/admin area


deemurphy

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.