SHARE
TWEET

proses_login

maradhon Dec 30th, 2018 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. include "../koneksi/koneksi.php";
  4. if(isset($_POST['username']) && isset($_POST['password'])) {
  5.     $username = $_POST["username"];
  6.     $password = $_POST["password"];
  7.  
  8.     $query = mysqli_query($koneksi,"SELECT * FROM tbl_user WHERE username='$username' and password='$password'");
  9.     $result = mysqli_num_rows($query);
  10.     //var_dump($result);
  11.  
  12.     // Validasi Login
  13.     if ($result > 0){      
  14.         $_SESSION['username'] = $username;
  15.         $_SESSION['password'] = $password;
  16.         $_SESSION['status']   = "login";
  17.             header("Location: dasboard.php");
  18.         }else{
  19.             header("Location: index.php?error = gagal");
  20.         }
  21.                
  22.                
  23.        
  24.         if (empty ($username) && empty ($password)){
  25.             header ("Location: index.php?error = notusername&password");
  26.             exit();
  27.             }
  28.             else if(empty ($username)){
  29.             header ("Location: index.php?error = notusername");
  30.             exit();
  31.             }
  32.             else if(empty ($password)){
  33.             header ("Location: index.php?error = notpassword");
  34.             exit();
  35.             }
  36.  
  37. } else {
  38.     header ("Location: index.php?error=notlogin");
  39.     exit();
  40. }
  41. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top