Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.46 KB | None | 0 0
  1. //login.php
  2. <?php session_start();
  3. include "../config.php";
  4.  
  5. if(isset($_POST['submit']))
  6. {
  7.     $errors     = array();
  8.     $username = mysqli_real_escape_string($conn,$_POST['username']);
  9.   $password = mysqli_real_escape_string($conn,$_POST['password']);
  10.  
  11.     if (empty($username) && empty($password))
  12.   {
  13.     echo "<script language='javascript'>alert('Isikan USERNAME dan PASSWORD'); location.replace('index.php')</script>";
  14.   }
  15.   elseif (empty($username))
  16.   {              
  17.     echo "<script language='javascript'>alert('Isikan USERNAME'); location.replace('index.php')</script>";
  18.   }
  19.   elseif (empty($password))
  20.   {
  21.     echo "<script language='javascript'>alert('Isikan PASSWORD'); location.replace('index.php')</script>";
  22.   }
  23.  
  24.   $sql    = "SELECT * FROM user WHERE username = '$username' ";
  25.   $result = mysqli_query($conn, $sql);
  26.   $data   = mysqli_fetch_array($result);
  27.   if (mysqli_num_rows($result) > 0)
  28.   {
  29.     if(password_verify($password, $data['password']))
  30.     {
  31.       if(empty($errors))
  32.       {
  33.         // Menyimpan session login
  34.         $_SESSION['id_user']    = $data['id_user'];   // id user
  35.         $_SESSION['nama']       = $data['nama'];      // nama user
  36.         $_SESSION['username']     = $data['username'];  // username user
  37.         $_SESSION['usertype']   = $data['usertype'];  // tipe user
  38.         $_SESSION['access']     = $data['access'];    // hak akses user
  39.        
  40.         if($data['usertype'] == 'admin')
  41.         {
  42.           echo "<script language='javascript'>alert('Anda berhasil Login sebagai Admin'); location.replace('home.php')</script>";
  43.         }
  44.     }
  45.       else
  46.       {
  47.         echo "<script>alert('PASSWORD SALAH!');history.go(-1)</script>";
  48.       }
  49.  }
  50.     else
  51.       echo "<script>alert('USERNAME yang Anda masukkan tidak terdaftar!');history.go(-1)</script>";
  52.     }
  53. }
  54.   else
  55.   {
  56.     echo "<script>alert('Pencet dulu tombolnya!');history.go(-1)</script>";
  57.   }
  58. ?>
  59.  
  60. //yang ini cek_login.php
  61. <?php
  62.  
  63. if (!isset($_SESSION['username']))
  64. {
  65.     echo "<string language='javascript'>
  66.             alert('HARAP LOGIN DULU');
  67.             location.replace('index.php')
  68.             </script>";
  69. }else{}
  70. ?>
  71.  
  72. //ini home.php
  73. <?php
  74. include '../config.php';
  75. include '../setting/cek_login.php';
  76. include '../setting/cek_session.php';
  77. include '../setting/setting.php';
  78.  
  79. ?>
  80. <!DOCTYPE html>
  81. <html>
  82. <head>
  83. <meta charset="utf-8">
  84.     <title>Dashboard </title>
  85.     <meta content='width=device-width,initial-scale=1, maximum-scale-1, user-scalable=no' name='viewport'>
  86.  
  87.     <link href="template/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  88.  
  89.     <link href="template/font-awesome4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
  90.  
  91.     <link href="template/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css"/>
  92.     <link href="template/dist/css/skins/skin-blue.min.css" rel="stylesheet" type="text/css" />
  93.  
  94.     <link rel="shortcut icon" href="../images/favicon.ico" />
  95. </head>
  96. <body class="skin-blue sidebar-mini">
  97.     <div class="wrapper">
  98.         <?php include "header.php" ?>
  99.  
  100.         <div class="content-wrapper">
  101.             <section class="content-header">
  102.             <h1>Dashboard</h1>
  103.             <ol class="breadcumb">
  104.              <li><a href="#"><i class="fa fa-dashboard"></i>Home</a></li>
  105.              <li class="active">Dashboard</li>
  106.             </ol>  
  107.             </section>
  108.             <section class="content">
  109.                 <div class="row">
  110.                  <?php include 'record.php'; ?>
  111.                 </div>
  112.             </section>
  113.  
  114.         </div>
  115.          <?php include "footer.php" ?>
  116.     </div>
  117.  
  118.     <?php include 'js.php'; ?>
  119. </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement