Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include "inc/koneksi.php";
- if(@$_SESSION['admin'] || @$_SESSION['operator']) {
- header("location: index.php");
- } else {
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
- <title>NF Jati Mekar</title>
- <!-- Bootstrap -->
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <script src="js/bootstrap.min.js"></script>
- <script src="https://ajax.googleapis.com/ajax/li/jquery/1.11.3/jquery.min.js"></script>
- <script type="text/javascript" src="jquery.validate.js"></script>
- <script type="text/javascript">
- $('form').validate({
- rules: {
- firstname: {
- minlength: 1,
- maxlength: 15,
- required: true
- },
- lastname: {
- minlength: 1,
- maxlength: 10,
- required: true
- }
- },
- highlight: function(element) {
- $(element).closest('.form-group').addClass('has-error');
- },
- unhighlight: function(element) {
- $(element).closest('.form-group').removeClass('has-error');
- },
- errorElement: 'span',
- errorClass: 'help-block',
- errorPlacement: function(error, element) {
- if (element.parent('.input-group').length) {
- error.insertAfter(element.parent());
- } else {
- error.insertAfter(element);
- }
- }
- });
- </script>
- <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
- <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
- <!--[if lt IE 9]>
- <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
- <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
- <![endif]-->
- <style type="text/css">
- body{
- background-color: #eee;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <p><br/></p>
- <div class="row">
- <div class="col-xs-6 col-sm-4"></div>
- <div class="col-xs-6 col-sm-4"></div>
- <div class="clearfix visible-xs-block"></div>
- <div class="col-xs-6 col-sm-4">
- <div class="panel panel-info">
- <div class="panel-body">
- <div class="page-header">
- <h3><p class="text-center">Login Area</p></h3>
- </div>
- <form role="form" action="" method="POST">
- <div class="form-group">
- <label class="control-label" for="firstname">Username</label>
- <div class="input-group">
- <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
- <input type="text" name="firstname" class="form-control" placeholder="username" />
- </div>
- </div>
- <div class="form-group">
- <label class="control-label" for="lastname">Password</label>
- <div class="input-group">
- <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
- <input type="text" name="lastname" class="form-control" id="exampleInputPassword1" placeholder="Password" />
- </div>
- </div>
- <hr/>
- <button type="button" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Daftar</button>
- <button type="submit" name="login" value="Login" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Login</button>
- <p><br/></p>
- </form>
- <?php
- $firstname = @$_POST['firstname'];
- $lastname = @$_POST['lastname'];
- $login = @$_POST['login'];
- if($login) {
- if($firstname == "") {
- echo "Username tidak boleh Kosong";
- } else if($lastname == "") {
- echo "Password tidak boleh kosong";
- } else {
- $sql = mysql_query("select * from tb_login where username = '$user' and password = md5('$pass')") or die (mysql_error());
- $data = mysql_fetch_array($sql);
- $cek = mysql_num_rows($sql);
- if($cek >= 1) {
- if($data['level'] == "admin") {
- @$_SESSION['admin'] = $data['kode_user'];
- header("location: index.php");
- } else if($data['level'] == "operator") {
- @$_SESSION['operator'] = $data['kode_user'];
- header("location: index.php");
- }
- } else {
- echo "login gagal";
- }
- }
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
- <!-- Include all compiled plugins (below), or include individual files as needed -->
- </body>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement