Guest User

Untitled

a guest
Aug 20th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <!doctype html>
  3. <html lang="en">
  4. <head>
  5. <!-- Required meta tags -->
  6. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8. <!-- Bootstrap CSS -->
  9. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
  10. integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  11. <link rel="stylesheet" type="text/css" href="style.css">
  12. <title>Integração transporte</title>
  13. </head>
  14. <body>
  15. <div class="login-page">
  16. <div class="form">
  17. <p>Integração Transporte</p>
  18. <br>
  19. <form class="login-form" action="includes/login.inc.php" method="POST">
  20. <input type="text" name="uid" placeholder="nome de usuário ou e-mail"/>
  21. <input type="password" name="pwd" placeholder="senha"/>
  22. <button type="submit" name="submit">Login</button>
  23. </form>
  24. </div>
  25. </div>
  26. <!-- Optional JavaScript -->
  27. <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  28. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
  29. integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
  30. crossorigin="anonymous"></script>
  31. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
  32. integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
  33. crossorigin="anonymous"></script>
  34. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
  35. integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
  36. crossorigin="anonymous"></script>
  37. </body>
  38. </html>
  39.  
  40. <?php
  41.  
  42. session_start();
  43.  
  44.  
  45. if (isset($_POST['submit'])) {
  46. echo error_reporting(-1);
  47.  
  48. include 'dbh.inc.php';
  49.  
  50. $uid = mysqli_real_escape_string($conn, $_POST['uid']);
  51. $pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
  52.  
  53. //Errors
  54. //Check if inputs are empty
  55. if (empty($uid) || empty($pwd)) {
  56. header("Location: ../index.php?login=empty");
  57. exit();
  58. } else {
  59. $sql = "SELECT * FROM users WHERE user_uid = '$uid' OR user_email = '$uid'";
  60. $result = mysqli_query($conn, $sql);
  61. $resultCheck = mysqli_num_rows($result);
  62. if ($resultCheck < 1) {
  63. header("Location: ../index.php?login=error");
  64. exit();
  65. } else {
  66. if ($row = mysqli_fetch_assoc($result)) {
  67.  
  68. $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
  69. if ($hashedPwdCheck == false) {
  70. header("Location: ../index.php?login=empty");
  71. exit();
  72. } elseif ($hashedPwdCheck == true) {
  73. //Login the user here
  74. $_SESSION['u_id'] = $row['user_id'];
  75. $_SESSION['u_first'] = $row['user_first'];
  76. $_SESSION['u_last'] = $row['user_last'];
  77. $_SESSION['u_email'] = $row['user_email'];
  78. $_SESSION['u_uid'] = $row['user_uid'];
  79.  
  80.  
  81. header("Location: ../index.php?login=success");
  82. exit();
  83. }
  84. }
  85. }
  86. }
  87.  
  88. } else {
  89. header("Location: ../index.php?login=error");
  90. exit();
  91. }
  92.  
  93. <?php
  94. /**
  95. * Created by PhpStorm.
  96. * User: root
  97. * Date: 17/08/18
  98. * Time: 18:43
  99. */
  100. #Dados para a conexão com o banco de dados
  101. $dbServername = "localhost";
  102. $dbUsername = "root";
  103. $dbPassword = "Lucas@09";
  104. $dbName = "dbtest";
  105.  
  106. #Executa a conexão com o MySQL
  107. $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
Add Comment
Please, Sign In to add comment