Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in']!==true) {
- header('Location: index.php');
- mysql_error();
- }
- $hostname = "localhost";
- //Konfigurasi MySQL
- $user_db="root";//tuliskan root untuk default DB location MySQL
- $pass_db="";//Password mySql, kosongkan bila tidak terdefine
- $dbName="eKerja";//nama database yang ingin terhubung
- mysql_connect($hostname,$user_db,$pass_db);
- mysql_select_db($dbName) or die("Connect Failed !! :" .mysql_error());
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>eKerja || Admin Login</title>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
- <meta name="description" content="">
- <meta name="author" content="">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <!-- Bootstrap core CSS -->
- <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
- <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
- <link href="../css/ie10-viewport-bug-workaround.css" rel="stylesheet" type="text/css"/>
- <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
- <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
- <script src="../js/ie-emulation-modes-warning.js" type="text/javascript"></script>
- <!-- HTML5 Shim and Respond.js 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/libs/html5shiv/3.7.0/
- html5shiv.js"></script>
- <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/
- respond.min.js"></script>
- <![endif]-->
- </head>
- <body style="background-color: #ccffcc">
- <div class="container">
- <div class="col-lg-12 col-md-6 col-sm-8">
- <div class="row" style="margin-top: 20px;">
- <h1 align="center" style="font-size: 100px; font-family: Edwardian Script ITC;">eKerja Admin</h1>
- </div>
- <div class="row">
- <div class="panel panel-default" style="margin-left: 400px; margin-right: 400px;margin-top: 60px;">
- <div class="panel-heading" align="center">
- <h1 align="center" style="font-size: 25px;margin-top: 10px;">Login</h1>
- </div>
- <div class="panel-body" style="background-color: #00ffff">
- <form class="form-horizontal" role="form" method="POST" action="" >
- <div class="form-group">
- <label for="firstname" class="col-sm-2 control-label">Username</label>
- <div class="col-sm-10">
- <input style="width: 200px;margin-left: 25px;"type="text" class="form-control" id="USERNAME" name="USERNAME" placeholder="Username">
- </div>
- </div>
- <div class="form-group">
- <label for="lastname" class="col-sm-2 control-label">Password</label>
- <div class="col-sm-10">
- <input style="width: 200px;margin-left: 25px;" type="password" class="form-control" id="PASSWORD" name="PASSWORD_ADMIN" placeholder="Password">
- </div>
- </div>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <div class="checkbox" style="margin-left: 23px;">
- <label>
- <input type="checkbox"> Remember me
- </label>
- </div>
- </div>
- </div>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <button style="margin-left: 23px;" type="submit" class="btn btn-default btn-primary" name="masuk">Sign in</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- <?php
- if (isset($_POST['USERNAME'])) {
- $Username=$_POST['USERNAME'];
- $Password=$_POST['PASSWORD_ADMIN'];
- $query="SELECT * FROM Admin WHERE Username_Admin='$Username' && Password_Admin='$Password'";
- $result=mysql_query($query);
- if (mysql_num_rows($result)) {
- $data = mysql_fetch_assoc($result);
- $_SESSION['logged_in']=true;
- $_SESSION['USERNAME']=$data['Username_Admin'];
- header('Location: index.php');
- }else{
- echo "Login Gagal";
- }
- // if ($data=mysql_fetch_array($result)) {
- // $_SESSION['logged_in']=true;
- // $_SESSION['USERNAME']=$_POST['USERNAME'];
- // header('location: index.php');
- // }else if ($USERNAME=="" or $PASSWORD=="") {
- // $_SESSION['kosong']='kosong';
- // header('location: index.php');
- // }else{
- // $_SESSION['salah']='salah';
- // header('location: index.php')
- // }
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
- <script src="../js/jquery-3.1.1.min.js" type="text/javascript"></script>
- <!-- Include all compiled plugins (below), or include individual files as needed -->
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment