I try to implement user authentication, using $_SERVER['PHP_AUTH_USER'].
On my test environment (my laptop with a WAMP implementation) it works succesfully but on my hosted environment it doesn't work.
Even if I use the code below, the server gives a pop-up, asking a username and password and keeps giving the pop-up.
Do I need to change some seetings on the PHP server or has anybody a clou?
- Code: Select all
<?php
$username = "1234";
$password = "5678";
if( !isset( $_SERVER['PHP_AUTH_USER'] ) || !isset( $_SERVER['PHP_AUTH_PW'] ))
{
header("WWW-Authenticate: Basic realm=\"Authentication Server\"");
header("HTTP/1.0 401 Unauthorized");
//echo "Login Unsuccesfull";
}
else
{
echo "Welcome you logged in succesfully!";
}
?>