Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 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. <link rel="stylesheet" href="../css/bootstrap.css"/>
  22. <link rel="stylesheet" href="../css/bootstrapValidator.css"/>
  23.  
  24. <script type="text/javascript" src="../js/jquery-2.1.4.min.js"></script>
  25. <script type="text/javascript" src="../js/bootstrap.min.js"></script>
  26. <script type="text/javascript" src="../js/bootstrapValidator.js"></script>
  27. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  28. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  29. <!--[if lt IE 9]>
  30. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  31. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  32. <![endif]-->
  33. <style type="text/css">
  34. body{
  35. background-color: #eee;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40.  
  41. <div class="container">
  42. <p><br/></p>
  43. <div class="row">
  44. <section>
  45. <div class="col-xs-6 col-sm-4"></div>
  46. <div class="col-xs-6 col-sm-4"></div>
  47. <div class="clearfix visible-xs-block"></div>
  48. <div class="col-xs-6 col-sm-4">
  49. <div class="panel panel-info">
  50. <div class="panel-body">
  51. <div class="page-header">
  52. <h3><p class="text-center">Login Area</p></h3>
  53. </div>
  54. <form id="defaultForm" action="" method="POST">
  55. <div class="form-group">
  56. <label class="control-label" for="firstname">Username</label>
  57. <div class="input-group">
  58. <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
  59. <input type="text" name="user" class="form-control" placeholder="username" />
  60. </div>
  61. </div>
  62. <div class="form-group">
  63. <label for="exampleInputPassword1">Password</label>
  64. <div class="input-group">
  65. <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
  66. <input type="password" name="pass" class="form-control" placeholder="Password" />
  67. </div>
  68. </div>
  69. <hr/>
  70. <button type="button" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Daftar</button>
  71. <button type="submit" name="login" value="Login" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Login</button>
  72. <p><br/></p>
  73. </form>
  74. <?php
  75. $user = @$_POST['user'];
  76. $pass = @$_POST['pass'];
  77. $login = @$_POST['login'];
  78.  
  79. if($login) {
  80. if($user == "") {
  81. echo "Username tidak boleh Kosong";
  82. } else if($pass == "") {
  83. echo "Password tidak boleh kosong";
  84. } else {
  85. $sql = mysql_query("select * from tb_login where username = '$user' and password = md5('$pass')") or die (mysql_error());
  86. $data = mysql_fetch_array($sql);
  87. $cek = mysql_num_rows($sql);
  88. if($cek >= 1) {
  89. if($data['level'] == "admin") {
  90. @$_SESSION['admin'] = $data['kode_user'];
  91. header("location: index.php");
  92. } else if($data['level'] == "operator") {
  93. @$_SESSION['operator'] = $data['kode_user'];
  94. header("location: index.php");
  95. }
  96. } else {
  97. echo "Username atau Password salah";
  98. }
  99. }
  100. }
  101. ?>
  102. </div>
  103. </div>
  104. </div>
  105. </section>
  106. </div>
  107. </div>
  108.  
  109. <script type="text/javascript">
  110. $(document).ready(function() {
  111. $('#defaultForm').bootstrapValidator({
  112. message: 'This value is not valid',
  113. submitHandler: function(validator, form) {
  114. // validator is the BootstrapValidator instance
  115. // form is the jQuery object present the current form
  116. form.find('.alert').html('Thanks for signing up. Now you can sign in as ' + validator.getFieldElement('username').val()).show();
  117. },
  118. fields: {
  119. user: {
  120. message: 'The username is not valid',
  121. validators: {
  122. notEmpty: {
  123. message: 'The username is required and can\'t be empty'
  124. },
  125. stringLength: {
  126. min: 6,
  127. max: 30,
  128. message: 'The username must be more than 6 and less than 30 characters long'
  129. },
  130. regexp: {
  131. regexp: /^[a-zA-Z0-9_\.]+$/,
  132. message: 'The username can only consist of alphabetical, number, dot and underscore'
  133. }
  134. }
  135. },
  136. pass: {
  137. validators: {
  138. notEmpty: {
  139. message: 'The password is required and can\'t be empty'
  140. }
  141. }
  142. }
  143. }
  144. });
  145. });
  146. </script>
  147.  
  148. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  149. <script src="https://ajax.googleapis.com/ajax/li/jquery/1.11.3/jquery.min.js"></script>
  150. <!-- Include all compiled plugins (below), or include individual files as needed -->
  151. <script src="js/bootstrap.min.js"></script>
  152. </body>
  153. </html>
  154.  
  155. <?php
  156. }
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement