Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //login.php
- <?php session_start();
- include "../config.php";
- if(isset($_POST['submit']))
- {
- $errors = array();
- $username = mysqli_real_escape_string($conn,$_POST['username']);
- $password = mysqli_real_escape_string($conn,$_POST['password']);
- if (empty($username) && empty($password))
- {
- echo "<script language='javascript'>alert('Isikan USERNAME dan PASSWORD'); location.replace('index.php')</script>";
- }
- elseif (empty($username))
- {
- echo "<script language='javascript'>alert('Isikan USERNAME'); location.replace('index.php')</script>";
- }
- elseif (empty($password))
- {
- echo "<script language='javascript'>alert('Isikan PASSWORD'); location.replace('index.php')</script>";
- }
- $sql = "SELECT * FROM user WHERE username = '$username' ";
- $result = mysqli_query($conn, $sql);
- $data = mysqli_fetch_array($result);
- if (mysqli_num_rows($result) > 0)
- {
- if(password_verify($password, $data['password']))
- {
- if(empty($errors))
- {
- // Menyimpan session login
- $_SESSION['id_user'] = $data['id_user']; // id user
- $_SESSION['nama'] = $data['nama']; // nama user
- $_SESSION['username'] = $data['username']; // username user
- $_SESSION['usertype'] = $data['usertype']; // tipe user
- $_SESSION['access'] = $data['access']; // hak akses user
- if($data['usertype'] == 'admin')
- {
- echo "<script language='javascript'>alert('Anda berhasil Login sebagai Admin'); location.replace('home.php')</script>";
- }
- }
- else
- {
- echo "<script>alert('PASSWORD SALAH!');history.go(-1)</script>";
- }
- }
- else
- echo "<script>alert('USERNAME yang Anda masukkan tidak terdaftar!');history.go(-1)</script>";
- }
- }
- else
- {
- echo "<script>alert('Pencet dulu tombolnya!');history.go(-1)</script>";
- }
- ?>
- //yang ini cek_login.php
- <?php
- if (!isset($_SESSION['username']))
- {
- echo "<string language='javascript'>
- alert('HARAP LOGIN DULU');
- location.replace('index.php')
- </script>";
- }else{}
- ?>
- //ini home.php
- <?php
- include '../config.php';
- include '../setting/cek_login.php';
- include '../setting/cek_session.php';
- include '../setting/setting.php';
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Dashboard </title>
- <meta content='width=device-width,initial-scale=1, maximum-scale-1, user-scalable=no' name='viewport'>
- <link href="template/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
- <link href="template/font-awesome4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
- <link href="template/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css"/>
- <link href="template/dist/css/skins/skin-blue.min.css" rel="stylesheet" type="text/css" />
- <link rel="shortcut icon" href="../images/favicon.ico" />
- </head>
- <body class="skin-blue sidebar-mini">
- <div class="wrapper">
- <?php include "header.php" ?>
- <div class="content-wrapper">
- <section class="content-header">
- <h1>Dashboard</h1>
- <ol class="breadcumb">
- <li><a href="#"><i class="fa fa-dashboard"></i>Home</a></li>
- <li class="active">Dashboard</li>
- </ol>
- </section>
- <section class="content">
- <div class="row">
- <?php include 'record.php'; ?>
- </div>
- </section>
- </div>
- <?php include "footer.php" ?>
- </div>
- <?php include 'js.php'; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement