Advertisement
aghinya35

index.php

May 26th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2.     include "koneksi.php";
  3.     include "include/session_check.php";
  4. ?>
  5.  
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9.     <title>Login</title>
  10. </head>
  11. <body>
  12.     <center>
  13.         <form action="" method="post">
  14.             <h1>Login</h1>         
  15.             <input type="text" name="username"><br>
  16.             <input type="password" name="password"><br>
  17.             <input type="submit" name="login" value="LOGIN">
  18.         </form>
  19.     </center>
  20. </body>
  21. </html>
  22.  
  23.  
  24. <?php
  25. if(isset($_POST['login'])){
  26.     $username = $_POST['username'];
  27.     $password = $_POST['password'];
  28.    
  29.     $test = mysql_query("SELECT * FROM pegawai WHERE username ='$username' and password = '$password'");
  30.    
  31.     if(mysql_num_rows($test) == TRUE){
  32.         $fetch = mysql_fetch_array($test);
  33.         $_SESSION['username']  = $fetch['username'];
  34.         $_SESSION['id_jabatan'] = $fetch['id_jabatan'];
  35.  
  36.         if ($_SESSION['id_jabatan']==1) {
  37.             $_SESSION['nama_p']=$fetch['nama_p'];
  38.             header("location:admin/index.php");
  39.         } else {
  40.             $_SESSION['nama_p']=$fetch['nama_p'];
  41.             header("location:entry/index.php");
  42.         }
  43.        
  44.        
  45.        
  46.     }else{
  47.       echo ("<script language='JavaScript'>
  48.             window.alert('Gagal Login , Ulangi!!')
  49.             window.location.href='index.php'
  50.             </script>");
  51.     }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement