Guest User

login

a guest
May 6th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.73 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in']!==true) {
  4.         header('Location: index.php');
  5.         mysql_error();
  6.     }
  7.     $hostname = "localhost";
  8.     //Konfigurasi MySQL
  9.     $user_db="root";//tuliskan root untuk default DB location MySQL
  10.     $pass_db="";//Password mySql, kosongkan bila tidak terdefine
  11.     $dbName="eKerja";//nama database yang ingin terhubung
  12.  
  13.     mysql_connect($hostname,$user_db,$pass_db);
  14.     mysql_select_db($dbName) or die("Connect Failed !! :" .mysql_error());
  15.     ?>
  16. <!DOCTYPE html>
  17. <html>
  18.     <head>
  19.         <title>eKerja || Admin Login</title>
  20.         <meta charset="utf-8">
  21.         <meta http-equiv="X-UA-Compatible" content="IE=edge">
  22.         <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  23.         <meta name="description" content="">
  24.         <meta name="author" content="">
  25.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  26.         <!-- Bootstrap core CSS -->
  27.         <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
  28.  
  29.         <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  30.         <link href="../css/ie10-viewport-bug-workaround.css" rel="stylesheet" type="text/css"/>
  31.  
  32.         <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
  33.         <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
  34.         <script src="../js/ie-emulation-modes-warning.js" type="text/javascript"></script>
  35.  
  36.         <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  37.         <!-- WARNING: Respond.js doesn't work if you view the page
  38.         via file:// -->
  39.         <!--[if lt IE 9]>
  40.         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/
  41.         html5shiv.js"></script>
  42.         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/
  43.         respond.min.js"></script>
  44.         <![endif]-->
  45.     </head>
  46.     <body style="background-color: #ccffcc">
  47.         <div class="container">
  48.             <div class="col-lg-12 col-md-6 col-sm-8">
  49.                 <div class="row" style="margin-top: 20px;">
  50.                     <h1 align="center" style="font-size: 100px; font-family: Edwardian Script ITC;">eKerja Admin</h1>
  51.                 </div>
  52.                 <div class="row">
  53.                     <div class="panel panel-default" style="margin-left: 400px; margin-right: 400px;margin-top: 60px;">
  54.                         <div class="panel-heading" align="center">
  55.                             <h1 align="center" style="font-size: 25px;margin-top: 10px;">Login</h1>
  56.                         </div>
  57.                         <div class="panel-body" style="background-color: #00ffff">
  58.                             <form class="form-horizontal" role="form" method="POST" action="" >
  59.                                 <div class="form-group">
  60.                                     <label for="firstname" class="col-sm-2 control-label">Username</label>
  61.                                     <div class="col-sm-10">
  62.                                         <input style="width: 200px;margin-left: 25px;"type="text" class="form-control" id="USERNAME" name="USERNAME" placeholder="Username">
  63.                                     </div>
  64.                                 </div>
  65.                                 <div class="form-group">
  66.                                     <label for="lastname" class="col-sm-2 control-label">Password</label>
  67.                                     <div class="col-sm-10">
  68.                                         <input style="width: 200px;margin-left: 25px;" type="password" class="form-control" id="PASSWORD" name="PASSWORD_ADMIN" placeholder="Password">
  69.                                     </div>
  70.                                 </div>
  71.                                 <div class="form-group">
  72.                                     <div class="col-sm-offset-2 col-sm-10">
  73.                                         <div class="checkbox" style="margin-left: 23px;">
  74.                                             <label>
  75.                                                 <input type="checkbox"> Remember me
  76.                                             </label>
  77.                                         </div>
  78.                                     </div>
  79.                                 </div>
  80.                                 <div class="form-group">
  81.                                     <div class="col-sm-offset-2 col-sm-10">
  82.                                         <button style="margin-left: 23px;" type="submit" class="btn btn-default btn-primary" name="masuk">Sign in</button>
  83.                                     </div>
  84.                                 </div>
  85.                             </form>
  86.                         </div>
  87.                     </div>
  88.                     <?php
  89.                         if (isset($_POST['USERNAME'])) {
  90.                             $Username=$_POST['USERNAME'];
  91.                             $Password=$_POST['PASSWORD_ADMIN'];
  92.  
  93.                             $query="SELECT * FROM Admin WHERE Username_Admin='$Username' && Password_Admin='$Password'";
  94.                             $result=mysql_query($query);
  95.                             if (mysql_num_rows($result)) {
  96.                                 $data = mysql_fetch_assoc($result);
  97.                                 $_SESSION['logged_in']=true;
  98.                                 $_SESSION['USERNAME']=$data['Username_Admin'];
  99.                                 header('Location: index.php');
  100.                             }else{
  101.                                 echo "Login Gagal";
  102.                             }
  103.                             // if ($data=mysql_fetch_array($result)) {
  104.                             //     $_SESSION['logged_in']=true;
  105.                             //     $_SESSION['USERNAME']=$_POST['USERNAME'];
  106.                             //     header('location: index.php');
  107.                             // }else if ($USERNAME=="" or $PASSWORD=="") {
  108.                             //     $_SESSION['kosong']='kosong';
  109.                             //     header('location: index.php');
  110.                             // }else{
  111.                             //     $_SESSION['salah']='salah';
  112.                             //     header('location: index.php')
  113.                             // }
  114.                         }
  115.                     ?>
  116.                 </div>
  117.             </div>
  118.         </div>
  119.     </div>
  120.     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  121.     <script src="../js/jquery-3.1.1.min.js" type="text/javascript"></script>
  122.     <!-- Include all compiled plugins (below), or include individual files as needed -->
  123.     <script src="js/bootstrap.min.js"></script>
  124. </body>
  125. </html>
Add Comment
Please, Sign In to add comment