0
I have a problem, that when the user logs in, correct, shows a div that displays the message "Welcome" ( and I would like you to show the username ) and it does not show, I would also like that if this error showed a div similar only to the message "Fill in the fields correctly".
Follow the PHP code:
<?php
if(isset($_GET('acao'])){
if(!isset($_POST['logar'])){
$acao = $_GET['acao'];
if(acao=='negado'){
echo '<strong>Erro!</strong> Você precisa estar logado';
}
}
}
if(isset($_POST['logar'])){
//recuperar dados do form
$email = trim(strip_tags($_POST['email']));
$senha = trim(strip_tags($_POST['senha']));
//selecionar banco de dados
$select = "SELECT * FROM usuario WHERE BINARY email=:email AND BINARY senha=:senha";
try{
$result = $conexao->prepare($select);
$row=$result->fetch(PDO::FETCH_ASSOC);
$usuario= $row['nomeUsuario'];
$result->bindParam(':email',$email, PDO::PARAM_STR);
$result->bindParam(':senha',$senha, PDO::PARAM_STR);
$result->execute();
$contar=$result->rowCount();
if($contar>0){
$email = $_POST['email'];
$senha = $_POST['senha'];
$_SESSION['email'] =$email;
$_SESSION['senha']= $senha;
echo('
<div class="row" style="margin-left:-145%;">
<div id="mensagem">Seja bem vindo <?php echo $usuario; ?></div>
</div>
'); // MSG SUCESSO
//header("Refresh:3, home.php");
}else{
echo('
<div class="row" style="margin-left:-145%;">
<div id="mensagem2">Preencha os campos corretamente</div>
</div>
');//MSG ERRO
header ("Refresh:3, index.php");
}
}catch(PDOException $error){
echo "Erro: ". $error->getMessage();
}
}
?>
all query data is returning? It is not the cause but it is an error if(acao=='negao'){ It has to be if($acao=='negao'){ missing $
– user60252
Yes, I had already put rsrs and copied the code from another pc that is offline. The login it does correctly, my two doubts are : - How to show the user name in the div of the message "Welcome" - How to show the error div that does not appear when login failed, whether it is wrong user or blank field.
– Thiago Luiz Ferreira Tavares
escape HTML, as if($count>0) { ? > ... <div>hit</div> <?php } Else { ? > Error <?php } ?>
– Felipe Duarte
Boy, your code has more error, it’s hard for us to go straight to the point you want, EM(isset($_GET('acao'])){ Short [ You could post the correct PHP code?
– user60252