Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement