Advertisement
Guest User

Untitled

a guest
Jan 18th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include "inc/koneksi.php";
  4.  
  5. if(@$_SESSION['admin'] || @$_SESSION['operator']) {
  6. header("location: index.php");
  7. } else {
  8. ?>
  9.  
  10. <!DOCTYPE html>
  11. <html lang="en">
  12. <head>
  13. <meta charset="utf-8">
  14. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  15. <meta name="viewport" content="width=device-width, initial-scale=1">
  16. <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  17. <title>NF Jati Mekar</title>
  18.  
  19. <!-- Bootstrap -->
  20. <link href="css/bootstrap.min.css" rel="stylesheet">
  21. <script src="js/bootstrap.min.js"></script>
  22. <script src="https://ajax.googleapis.com/ajax/li/jquery/1.11.3/jquery.min.js"></script>
  23. <script type="text/javascript" src="jquery.validate.js"></script>
  24. <script type="text/javascript">
  25. $('form').validate({
  26. rules: {
  27. firstname: {
  28. minlength: 1,
  29. maxlength: 15,
  30. required: true
  31. },
  32. lastname: {
  33. minlength: 1,
  34. maxlength: 10,
  35. required: true
  36. }
  37. },
  38. highlight: function(element) {
  39. $(element).closest('.form-group').addClass('has-error');
  40. },
  41. unhighlight: function(element) {
  42. $(element).closest('.form-group').removeClass('has-error');
  43. },
  44. errorElement: 'span',
  45. errorClass: 'help-block',
  46. errorPlacement: function(error, element) {
  47. if (element.parent('.input-group').length) {
  48. error.insertAfter(element.parent());
  49. } else {
  50. error.insertAfter(element);
  51. }
  52. }
  53. });
  54. </script>
  55. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  56. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  57. <!--[if lt IE 9]>
  58. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  59. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  60. <![endif]-->
  61. <style type="text/css">
  62. body{
  63. background-color: #eee;
  64. }
  65. </style>
  66. </head>
  67. <body>
  68.  
  69. <div class="container">
  70. <p><br/></p>
  71. <div class="row">
  72. <div class="col-xs-6 col-sm-4"></div>
  73. <div class="col-xs-6 col-sm-4"></div>
  74. <div class="clearfix visible-xs-block"></div>
  75. <div class="col-xs-6 col-sm-4">
  76. <div class="panel panel-info">
  77. <div class="panel-body">
  78. <div class="page-header">
  79. <h3><p class="text-center">Login Area</p></h3>
  80. </div>
  81. <form role="form" action="" method="POST">
  82. <div class="form-group">
  83. <label class="control-label" for="firstname">Username</label>
  84. <div class="input-group">
  85. <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
  86. <input type="text" name="firstname" class="form-control" placeholder="username" />
  87. </div>
  88. </div>
  89. <div class="form-group">
  90. <label class="control-label" for="lastname">Password</label>
  91. <div class="input-group">
  92. <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
  93. <input type="text" name="lastname" class="form-control" id="exampleInputPassword1" placeholder="Password" />
  94. </div>
  95. </div>
  96. <hr/>
  97. <button type="button" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Daftar</button>
  98. <button type="submit" name="login" value="Login" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Login</button>
  99. <p><br/></p>
  100. </form>
  101. <?php
  102. $firstname = @$_POST['firstname'];
  103. $lastname = @$_POST['lastname'];
  104. $login = @$_POST['login'];
  105.  
  106. if($login) {
  107. if($firstname == "") {
  108. echo "Username tidak boleh Kosong";
  109. } else if($lastname == "") {
  110. echo "Password tidak boleh kosong";
  111. } else {
  112. $sql = mysql_query("select * from tb_login where username = '$user' and password = md5('$pass')") or die (mysql_error());
  113. $data = mysql_fetch_array($sql);
  114. $cek = mysql_num_rows($sql);
  115. if($cek >= 1) {
  116. if($data['level'] == "admin") {
  117. @$_SESSION['admin'] = $data['kode_user'];
  118. header("location: index.php");
  119. } else if($data['level'] == "operator") {
  120. @$_SESSION['operator'] = $data['kode_user'];
  121. header("location: index.php");
  122. }
  123. } else {
  124. echo "login gagal";
  125. }
  126. }
  127. }
  128. ?>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134.  
  135. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  136. <!-- Include all compiled plugins (below), or include individual files as needed -->
  137. </body>
  138. </html>
  139.  
  140. <?php
  141. }
  142. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement