Guest User

Ask

a guest
Dec 11th, 2014
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1.  
  2. 1. login.php
  3.  
  4.  
  5.  
  6. `<?php
  7. session_start();
  8. include "koneksi.php";
  9. error_reporting(0);
  10. if (empty($_SESSION['username']) AND empty($_SESSION['password'])){include "index.php";}
  11. else{?><?php
  12. $sql = mysql_query("SELECT * FROM tb_user WHERE user_id = '$_SESSION[user_id]'");
  13. while ($data = mysql_fetch_array($sql))
  14. {
  15. $username= $data['user_username'];}?>
  16. <?php
  17. if ($_SESSION[level] == "1")
  18. if ($_SESSION[level] == "2"){echo "You're logged as admin! <a href='logout.php' title='Keluar!'>Keluar</a>";}
  19. if ($_SESSION[level] == "3"){echo "You're logged as user! <a href='logout.php' title='Keluar!'>Keluar</a>";}
  20. if ($_SESSION[level] == ""){echo "Kamu tidak memiliki akses kesini!";}
  21. ?><?php } ?>`
  22.  
  23.  
  24. 2. check.php `<?php
  25. session_start();//mulai session
  26. mysql_connect("localhost", "root", "");
  27. mysql_select_db("kepegawaian");
  28. $username = $_POST['username'];
  29. $password = md5($_POST['password']);
  30. //untuk mencegah sql injection
  31. //kita gunakan mysql_real_escape_string
  32. $username= mysql_real_escape_string($username);
  33. $password= mysql_real_escape_string ($password);
  34. $user = mysql_query("select * from tb_user where username='$username' and password='$password'");
  35. $tot= mysql_num_rows($user);
  36. $r= mysql_fetch_array($user);
  37. if ($tot > 0) {
  38. $_SESSION['username'] = $username;
  39. $_SESSION['password'] = $password;
  40. $_SESSION['level'] = $r['level'];
  41. if($r['level']=='1'){
  42. echo"<script>location.href='datapegawai.php'</script>";
  43. }elseif($r['level']=='2'){
  44. echo"<script>location.href='owner.php'</script>";
  45. }elseif($r['level']=='3'){
  46. echo"<script>location.href='home.php'</script>";}
  47. } else { echo"<script>location.href='index.php'</script>";}?>`
  48.  
  49.  
  50. 3. logout.php
  51.  
  52.  
  53.  
  54. `<?php
  55. session_start();
  56. unset($_SESSION['user']);
  57. session_destroy();echo"<meta http-equiv='refresh'content='0; url=login.php'>";
  58. ?>`
  59.  
  60. 4. datapegawai.php
  61.  
  62.  
  63.  
  64. `<?php
  65. $page = 'Data Pegawai';
  66. if(isset($_SESSION['user']))
  67. { header("Location: index.php");
  68. exit;
  69. }?>
  70. <!DOCTYPE html>
  71. <html lang= "en">
  72. <head>
  73. <meta charset = "utf-8">
  74. <title>Sistem Informasi Kepegawaian</title>
  75. <link rel = "stylesheet" href = "css/style.css">
  76. </head>
  77. <body><div id = "header">
  78. <div id = "name">
  79. </div>
  80. <div id = "gambar">
  81. <img src="images/pg.png" width="836px" height="457px" alt="pegawai">
  82. </div>
  83. </div>
  84. <div id = "flt">
  85. <div id="menu">
  86. <ul>
  87. <?php include 'menu.php';?>
  88. </ul></div></div>
  89. <div id = "main">
  90. <div id="content">
  91. <h1>Petunjuk Penggunaan</h1>
  92. <button type="submit" class="button">Pelajari Selengkapnya</button>
  93. </div>
  94. </div><div id = "footer">
  95. <div id="copyright">
  96. </div>
  97. </div>
  98. </body>
  99. </html>`
Advertisement
Add Comment
Please, Sign In to add comment