Advertisement
Guest User

index.php

a guest
Feb 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--[if lt IE 7 ]> <html lang="en" class="ie6 ielt8"> <![endif]-->
  3. <!--[if IE 7 ]> <html lang="en" class="ie7 ielt8"> <![endif]-->
  4. <!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
  5. <!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>ZyroLabs Login</title>
  9. <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
  10.  
  11. </head>
  12. <body>
  13. <div class="container">
  14. <section id="content">
  15. <form action="" method="POST">
  16. <h1>Login</h1>
  17. <div>
  18. <input type="text" placeholder="Username" required="" id="username" name="username" />
  19. </div>
  20. <div>
  21. <input type="password" placeholder="Password" required="" id="password" name="password" />
  22. </div>
  23. <div>
  24. <input type="submit" value="Log in" name="login" />
  25.  
  26. </div>
  27. </form><!-- form -->
  28.  
  29. </section><!-- content -->
  30. </div><!-- container -->
  31. </body>
  32. </html>
  33.  
  34.  
  35. <?php
  36. include ("koneksi.php");
  37. session_start();
  38. error_reporting(0);
  39.  
  40. if(isset ($_POST['login'])){
  41.  
  42. $username = $_POST['username'];
  43. $password = md5($_POST['password']);
  44. $md5=md5($password);
  45. $sql = mysql_query("SELECT * FROM tbl_akun WHERE username='$username' && password='$password'");
  46. $num = mysql_num_rows($sql);
  47.  
  48. if ($num==1) {
  49. // login benar //
  50. // memulai session
  51. if (isset($_SESSION['level']))
  52. {
  53. // jika level admin
  54. if ($_SESSION['level'] == "1")
  55. {
  56. header('location: admin/db.php');
  57. }
  58. // jika kondisi level user maka akan diarahkan ke halaman lain
  59. else if ($_SESSION['level'] == "2")
  60. {
  61. header('location: kasir/kasir.php');
  62. }
  63. }
  64. $_SESSION['username'] = $username;
  65. $_SESSION['password'] = $password;
  66. header("Location: admin/db.php");
  67. }else {
  68. //JIka Login Salah //
  69. ?>
  70.  
  71. <script languange="javascript">
  72. {
  73. alert("Username atau Password Salah");
  74. javascript:history.back();
  75. }
  76. </script>
  77. <?php
  78. }
  79. mysql_close();
  80. }
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement