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"/>
- <link rel="stylesheet" href="../css/bootstrap.css"/>
- <link rel="stylesheet" href="../css/bootstrapValidator.css"/>
- <script type="text/javascript" src="../js/jquery-2.1.4.min.js"></script>
- <script type="text/javascript" src="../js/bootstrap.min.js"></script>
- <script type="text/javascript" src="../js/bootstrapValidator.js"></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">
- <section>
- <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 id="defaultForm" 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="user" class="form-control" placeholder="username" />
- </div>
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Password</label>
- <div class="input-group">
- <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
- <input type="password" name="pass" class="form-control" 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
- $user = @$_POST['user'];
- $pass = @$_POST['pass'];
- $login = @$_POST['login'];
- if($login) {
- if($user == "") {
- echo "Username tidak boleh Kosong";
- } else if($pass == "") {
- 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 "Username atau Password salah";
- }
- }
- }
- ?>
- </div>
- </div>
- </div>
- </section>
- </div>
- </div>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#defaultForm').bootstrapValidator({
- message: 'This value is not valid',
- submitHandler: function(validator, form) {
- // validator is the BootstrapValidator instance
- // form is the jQuery object present the current form
- form.find('.alert').html('Thanks for signing up. Now you can sign in as ' + validator.getFieldElement('username').val()).show();
- },
- fields: {
- user: {
- message: 'The username is not valid',
- validators: {
- notEmpty: {
- message: 'The username is required and can\'t be empty'
- },
- stringLength: {
- min: 6,
- max: 30,
- message: 'The username must be more than 6 and less than 30 characters long'
- },
- regexp: {
- regexp: /^[a-zA-Z0-9_\.]+$/,
- message: 'The username can only consist of alphabetical, number, dot and underscore'
- }
- }
- },
- pass: {
- validators: {
- notEmpty: {
- message: 'The password is required and can\'t be empty'
- }
- }
- }
- }
- });
- });
- </script>
- <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
- <script src="https://ajax.googleapis.com/ajax/li/jquery/1.11.3/jquery.min.js"></script>
- <!-- Include all compiled plugins (below), or include individual files as needed -->
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement