Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'php/conn.php';
- if (isset($_POST['masuk'])) {
- $username = $_POST['username'];
- $userpass = $_POST['password'];
- $sql = mysqli_query($conn, "SELECT username, password, level FROM user WHERE username = '$username'");
- $r = mysqli_fetch_array($sql);
- if (mysqli_num_rows($sql) > 0) {
- if (password_verify($userpass, $r['password'])) {
- $_SESSION['level'] = $r['level'];
- header('location:index.php');
- die();
- } else {
- echo '<script language="javascript">
- window.alert("LOGIN GAGAL! Silakan coba lagi");
- window.location.href="./";
- </script>';
- }
- } else {
- echo '<script language="javascript">
- window.alert("LOGIN GAGAL! Silakan coba lagi");
- window.location.href="./";
- </script>';
- }
- }
- ?>
- <!DOCTYPE html><html>
- <head>
- <title>LOG IN</title>
- </head>
- <body>
- <form action="" method="POST">
- <input type="text" name="username"><br>
- <input type="password" name="password"><br>
- <div class="col s12 m12 l12 center-align"><input type="submit" name="masuk" class="btn waves-effect waves-default deep-blue"></div>
- <a href="reguser.php">Mendaftar</a>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement