0
Hi, I hope you can help me. I want to hide the Login and Register buttons from the index and show the message (hello) after Login. (the hello message is for test purposes only). I have already done some tests and even when logging in appears the buttons. Thank you and good coding :)
INDEX.PHP
<?php session_start();
include('PHP\login.php');
$usuario_status = $_SESSION['logged_in'];
if ($usuario_status === true) { ?>
<span><?php echo 'boas';?></span>
<?php } else {?>
<div class="botoes_RL">
<a class="btn_login" href="Login.php"><button>Login</button></a>
<a class="btn_register" href="Register.php"><button>Register</button></a>
</div>
<?php } ?>
Login.php
<?php
//Conecção á base de dados
require_once ('conexao.php');
//Se o botao de dar login for carregado da página loginForm.php
if(isset($_POST['enviar-form'])){
//Recolha dos dados inseridos pelo utilizador
$email = $_POST['email'];
//Incriptação da password
$passwords = md5($_POST['password_1']);
//Query
$login = mysqli_query($conn, "SELECT * FROM benchking.register WHERE email='$email' AND passwords='$passwords'");
//Verificar se os dados eram iguais com alguma das rows da DB
if (mysqli_num_rows($login) > 0){
$verificado = mysqli_query($conn, "SELECT * FROM qb44h66u_benchking.register WHERE verificado='1'");
if(mysqli_num_rows($verificado) > 0){
//Login efetuado com sucesso
$_SESSION['logged_in'] = true;
header('location: ../main.php');
}else{
//Erro
header('location: ../loginForm.php?erro=A conta ainda não foi ativada');
}
}else{
//Mensagem de error a informar que não foi possivel dar login
header('location: ../loginForm.php?erro=Email ou password incorretos');
}
}
//Encerra a conecção á base de dados
mysqli_close($conn);
?>