Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. login.php
- `<?php
- session_start();
- include "koneksi.php";
- error_reporting(0);
- if (empty($_SESSION['username']) AND empty($_SESSION['password'])){include "index.php";}
- else{?><?php
- $sql = mysql_query("SELECT * FROM tb_user WHERE user_id = '$_SESSION[user_id]'");
- while ($data = mysql_fetch_array($sql))
- {
- $username= $data['user_username'];}?>
- <?php
- if ($_SESSION[level] == "1")
- if ($_SESSION[level] == "2"){echo "You're logged as admin! <a href='logout.php' title='Keluar!'>Keluar</a>";}
- if ($_SESSION[level] == "3"){echo "You're logged as user! <a href='logout.php' title='Keluar!'>Keluar</a>";}
- if ($_SESSION[level] == ""){echo "Kamu tidak memiliki akses kesini!";}
- ?><?php } ?>`
- 2. check.php `<?php
- session_start();//mulai session
- mysql_connect("localhost", "root", "");
- mysql_select_db("kepegawaian");
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- //untuk mencegah sql injection
- //kita gunakan mysql_real_escape_string
- $username= mysql_real_escape_string($username);
- $password= mysql_real_escape_string ($password);
- $user = mysql_query("select * from tb_user where username='$username' and password='$password'");
- $tot= mysql_num_rows($user);
- $r= mysql_fetch_array($user);
- if ($tot > 0) {
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- $_SESSION['level'] = $r['level'];
- if($r['level']=='1'){
- echo"<script>location.href='datapegawai.php'</script>";
- }elseif($r['level']=='2'){
- echo"<script>location.href='owner.php'</script>";
- }elseif($r['level']=='3'){
- echo"<script>location.href='home.php'</script>";}
- } else { echo"<script>location.href='index.php'</script>";}?>`
- 3. logout.php
- `<?php
- session_start();
- unset($_SESSION['user']);
- session_destroy();echo"<meta http-equiv='refresh'content='0; url=login.php'>";
- ?>`
- 4. datapegawai.php
- `<?php
- $page = 'Data Pegawai';
- if(isset($_SESSION['user']))
- { header("Location: index.php");
- exit;
- }?>
- <!DOCTYPE html>
- <html lang= "en">
- <head>
- <meta charset = "utf-8">
- <title>Sistem Informasi Kepegawaian</title>
- <link rel = "stylesheet" href = "css/style.css">
- </head>
- <body><div id = "header">
- <div id = "name">
- </div>
- <div id = "gambar">
- <img src="images/pg.png" width="836px" height="457px" alt="pegawai">
- </div>
- </div>
- <div id = "flt">
- <div id="menu">
- <ul>
- <?php include 'menu.php';?>
- </ul></div></div>
- <div id = "main">
- <div id="content">
- <h1>Petunjuk Penggunaan</h1>
- <button type="submit" class="button">Pelajari Selengkapnya</button>
- </div>
- </div><div id = "footer">
- <div id="copyright">
- </div>
- </div>
- </body>
- </html>`
Advertisement
Add Comment
Please, Sign In to add comment