Guest User

Untitled

a guest
Nov 24th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. include_once '../back/login.php';
  2. if (!isset($_SESSION['log']))
  3. {
  4.  
  5. ?>
  6.  
  7. <html lang="pt-BR">
  8. <head>
  9. <title>TodoIF</title>
  10. <meta charset="utf-8">
  11. <!-- <link rel="stylesheet" type="text/css" href="front.css">-->
  12. </head>
  13. <body>
  14. <div class="tabs">
  15. <label for="tab1" id="tab_label" class="tab_label">LOGIN</label>
  16. <div class="tab_content"></div>
  17. <h2>BEM VINDO!</h2>
  18. <form method="post" action="../back/login.php">
  19. <label for="email">E-mail:</label>
  20. <input type="text" id="email" name="email"/><br><br>
  21. <label for="key">Senha:</label>
  22. <input type="text" type="password" name="senha"/><br><br>
  23.  
  24. <button type="submit" name="logar">Login</button>
  25.  
  26. <div class="links">
  27. <a href="" style="font-size: 14px;">Não tenho cadastro</a><br>
  28. <a href="">Esqueci minha senha</a>
  29. </div>
  30. </form>
  31. </div>
  32. </body>
  33. </html>
  34.  
  35. <?php
  36. }else
  37. {
  38. $_SESSION['msg'] = "Você já está logado";
  39. header("location: dashbord.php");
  40. }
  41. ?>
  42.  
  43. <?php
  44.  
  45. include_once 'connect.php';
  46. include_once 'bcrypt.php';
  47. include_once 'register.php';
  48. //include_once 'loginfront.php';
  49.  
  50. if(isset($_POST['logar']))
  51. {
  52. var_dump($_POST);
  53. $dbh= Conexao();
  54. $email= $_POST['email'];
  55. $password_user= $_POST['senha'];
  56.  
  57. try {
  58.  
  59. $sql= ("SELECT `id`, `email`, `password_user` FROM `users` WHERE email = '$email'");
  60. $result= $dbh->prepare($sql);
  61. $result->execute(array('email'=> $email,'senha'=> $password_user));
  62. $result= $result->fetch();
  63. var_dump($result);
  64. if (Bcrypt::check($password_user, $hash) == $hash) {
  65. session_start();
  66. $_SESSION["id"] = $result["id"];
  67. header("Location: ../front/dashbord.php");
  68. }else {
  69. echo "<script>alert('Login ou senha inválidos. Tente novamente')</script>";
  70. }
  71. }catch(PDOexception $error) {
  72. echo 'Erro ao fazer login.'.$error->getMessage();
  73. }
  74.  
  75. }
  76. ?>
Add Comment
Please, Sign In to add comment