Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2. include_once 'header.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <title></title>
  8. <link rel="stylesheet" type="text/css" href="style.css">
  9.  
  10. <body>
  11. <header>
  12.  
  13. </header>
  14.  
  15. <section>
  16.  
  17. <div class="nav-login">
  18. <form action="includes/loginprocess.php" method="POST">
  19. <input class="txtbox" type="text" name="username" placeholder="Username"><br>
  20. <input class="txtbox" type="password" name="userpass" placeholder="Password"><br>
  21. <button class="good-looking" type="submit" name="submit">Login</button>
  22. </form>
  23.  
  24. </div>
  25. </section>
  26.  
  27. </body>
  28. </html>
  29.  
  30. <?php
  31. session_start();
  32.  
  33. if(isset($_POST['submit'])) {
  34. include 'dbconn.php';
  35.  
  36. $username = mysqli_real_escape($conn, $_POST['username']);
  37. $userpass = mysqli_real_escape($conn, $_POST['userpass']);
  38.  
  39. if (empty($username) || empty($userpass)) {
  40. header("Location: ../index.php?login=empty");
  41. exit();
  42. } else {
  43. $sql = "SELECT * FROM samokslogin WHERE samokslogin_username='$username'";
  44. $result = mysqli_query($conn, $sql);
  45. $reultCheck = mysqli_num_rows($result);
  46. if($resultCheck < 1) {
  47. header("Location: ../index.php?login=error");
  48. exit();
  49. } else {
  50. if($row = mysqli_fetch_assoc($result)) {
  51. $LoginCheck = password_verify($pwd, $row['samokslogin_userpass']);
  52. if($LoginCheck == false) {
  53. header("Location: ../index.php?login=failed");
  54. exit();
  55. } elseif ($LoginCheck == true) {
  56. $_SESSION['u_id'] = $row['samokslogin_id'];
  57. $_SESSION['u_username'] = $row['samokslogin_username'];
  58. header("Location: ../index.php?login=success");
  59. exit();
  60. }
  61. }
  62. }
  63. }
  64. else {
  65. header("Location: ../index.php?login=failed");
  66. exit();
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement