ho trovato questo codice, provalo, ma a me sembra non possa funzionare
Codice PHP:
<?PHP
if(!isset($PHP_AUTH_USER))
{
Header("WWW-Authenticate: Basic realm=\"Xavier Protection\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Text to send if user hits Cancel button\n";
exit;
}
else
{
$user_passwords = array (
"nomeutente" => "password",
);
if (($PHP_AUTH_USER == "") || ($PHP_AUTH_PW == ""))
{
Header("HTTP/1.0 401 Unauthorized");
echo "Sorry, could find your password!";
exit;
}
else if (strcmp($user_passwords[$PHP_AUTH_USER],$PHP_AUTH_PW) == 0)
{
echo "This is the password protected page.";
exit;
}
else
{
Header("HTTP/1.0 401 Unauthorized");
echo "Sorry, could find your password!";
exit;
}
}
?>
prova dal codice a togliere le virgolette:
Codice PHP:
if (($PHP_AUTH_USER == "$username") && ($PHP_AUTH_PW == "$pwd")) {
//diventa:
if (($PHP_AUTH_USER == $username) && ($PHP_AUTH_PW == $pwd)) {