I have this code for the login.php:
this goes before the form I made witch is:PHP Code:<?PHP
session_start();
unset($_SESSION['usuario']);
unset($_SESSION['senha']);
session_destroy();
if(isset($_POST['submit'])){
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
session_start();
$_SESSION['usuario'] = $usuario;
$_SESSION['senha'] = $senha;
header('location: index.php');
}
?>
then in each page of the admin I check if the user is logged:PHP Code:<form name="form1" method="post" action="<?PHP echo($PHP_SELF); ?>">
<input name="usuario" type="text" class="caixa" id="usuario">
<input name="senha" type="text" class="caixa" id="senha" maxlength="6">
<input name="submit" type="submit" class="botao" value="Enviar">
</form>
then in the logoff script I set:PHP Code:<?PHP
session_start();
if(isset($_SESSION['usuario']) || isset($_SESSION['senha'])){
$usuariosql = $_SESSION['usuario'];
$senhasql = $_SESSION['senha'];
$dbcnx = @mysql_connect ('localhost', 'calesa', 'pass');
mysql_select_db('calesa');
$sqlprocura = "SELECT * FROM Admin WHERE Usuario = '$usuariosql' AND Senha = '$senhasql' ";
$query = mysql_query($sqlprocura);
$num = mysql_num_rows($query);
if($num != "0"){
header('location: index.php');
}
else{
header('location: login.php');
}
}
else{
header('location: login.php');
}
?>
what is wrong cause it is not working and Iīm getting to think Iīm stupid cause I canīt understand php and I canīt make anything work.PHP Code:<?PHP
session_start();
unset($_SESSION['usuario']);
unset($_SESSION['senha']);
session_destroy();
header('location: ../index.php');
?>
Thanks for the help.





Bookmarks