1
I created a very simple login and password system, but when I play them for the FTP, with the password and login that I inform, do not enter, stay on the login page.
<?php
// Definimos o nome de usuário e senha de acesso
$usuario = "fmc";
$senha = "lorga";
// Criamos uma função que exibirá uma mensagem de erro caso os dados estejam errados
function erro(){
// Definindo Cabeçalhos
header('WWW-Authenticate: Basic realm="Administracao"');
header('HTTP/1.0 401 Unauthorized');
// Mensagem que será exibida
echo "<script language='javascript' type='text/javascript'>alert('Área Restrita Você Não Tem Permissão, estamos lhe redirecionando para a página de solicitação de senha');window.location.href='solicitacao.php'</script>";
// Pára o carregamento da página
exit;
}
// Se as informações não foram setadas
if (!isset($_SERVER['PHP_AUTH_USER']) or !isset($_SERVER['PHP_AUTH_PW'])) {
erro();
}
// Se as informações foram setadas
else {
// Se os dados informados forem diferentes dos definidos
if ($_SERVER['PHP_AUTH_USER'] != $usuario or $_SERVER['PHP_AUTH_PW'] != $senha) {
erro();
}
}
require_once("includes/header.php");
?>
Localhost works normally, but the server itself does not work.
Are PHP versions on localhost and server the same? Do you know if your php.ini settings are the same as on the server?
– Diego
I can’t tell you Saul. I’ll check and tell you.
– José Júnior
Some suggestions to identify the problem: Check your version of PHP and compare with the production version; check the log apache errors; Use apache
var_dump()
to "debug" the code on the server– Jerfeson Guerreiro
Where the variable
$_SESSION
is initialized? Even simple, you don’t want to have/learn a more secure login code?– Gabriel Heming
Yes, but it’s only for information guards.
– José Júnior