Advertisement
ma_ul

login

May 4th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2.      session_start();
  3.      include 'php/conn.php';
  4.     if (isset($_POST['masuk'])) {
  5.         $username = $_POST['username'];
  6.         $userpass = $_POST['password'];
  7.         $sql = mysqli_query($conn, "SELECT username, password, level FROM user WHERE username = '$username'");
  8.         $r = mysqli_fetch_array($sql);
  9.         if (mysqli_num_rows($sql) > 0) {
  10.             if (password_verify($userpass, $r['password'])) {
  11.                 $_SESSION['level'] = $r['level'];
  12.                 header('location:index.php');
  13.                 die();
  14.             } else {
  15.                 echo '<script language="javascript">
  16.                        window.alert("LOGIN GAGAL! Silakan coba lagi");
  17.                        window.location.href="./";
  18.                      </script>';
  19.             }
  20.         } else {
  21.             echo '<script language="javascript">
  22.                    window.alert("LOGIN GAGAL! Silakan coba lagi");
  23.                    window.location.href="./";
  24.                  </script>';
  25.         }
  26.     }
  27. ?>
  28. <!DOCTYPE html><html>
  29. <head>
  30.     <title>LOG IN</title>
  31. </head>
  32. <body>
  33. <form action="" method="POST">
  34. <input type="text" name="username"><br>
  35. <input type="password" name="password"><br>
  36. <div class="col s12 m12 l12 center-align"><input type="submit" name="masuk" class="btn waves-effect waves-default deep-blue"></div>
  37. <a href="reguser.php">Mendaftar</a>
  38. </form>
  39. </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement