Advertisement
jsyz

Untitled

Aug 24th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.   <title>Citytrans Logistics | Log in</title>
  7.   <!-- Tell the browser to be responsive to screen width -->
  8.   <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  9.   <!-- Bootstrap 3.3.7 -->
  10.   <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">
  11.   <!-- Font Awesome -->
  12.   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  13.   <!-- Ionicons -->
  14.   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
  15.   <!-- Theme style -->
  16.   <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
  17.   <!-- SweetAlert -->
  18.   <link rel="stylesheet" href="../../plugins/SweetAlert/sweetalert.css">
  19.   <!-- SweetAlert JS -->
  20.   <script src="../../plugins/SweetAlert/sweetalert.min.js"></script>
  21.   <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  22.   <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  23.   <!--[if lt IE 9]>
  24.   <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  25.   <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  26.   <![endif]-->
  27.  
  28.   <!-- Google Font -->
  29.   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  30. </head>
  31. <body class="hold-transition login-page">
  32.  
  33. <!-- php for sessions -->
  34. <?php
  35.   session_start();
  36.   require($_SERVER['DOCUMENT_ROOT'] . '/config/db.php');
  37.   require($_SERVER['DOCUMENT_ROOT'] . '/config/cpp.php');
  38.  
  39.   //if form submitted, insert value into db
  40.   if (isset($_POST['username'])) {
  41.     //remove backlashes and escape special char
  42.     $username = stripslashes($_REQUEST['username']);
  43.     $username = mysqli_real_escape_string($conn,$username);
  44.     $password = stripslashes($_REQUEST['password']);
  45.     $password = mysqli_real_escape_string($conn,$password);
  46.  
  47.     //Checking is user existing in the database or not
  48.     $query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
  49.  
  50.     $result = mysqli_query($conn,$query) or die(mysql_error());
  51.  
  52.     $rows = mysqli_num_rows($result);
  53.  
  54.     if ($rows==1) {
  55.       ob_start();
  56.       $_SESSION['username'] = $username;
  57.       // Redirect user to index.php
  58.       header("Location: home.php", true, 301); exit;
  59.       ob_end_flush();
  60.     } else {
  61. ?>
  62.       <script type="text/javascript">
  63.         swal({
  64.           title: "Invalid username/password!",
  65.           text: "Please key in the correct username/password.",
  66.           timer: 1000,
  67.           showConfirmButton: true
  68.         });
  69.       </script>
  70. <?php
  71.     }
  72.   }
  73. ?>
  74.  
  75. <div class="login-box">
  76.   <div class="login-logo">
  77.     <a href="../../index.php"><b><?php echo $companyname; ?></b></a>
  78.   </div>
  79.   <!-- /.login-logo -->
  80.   <div class="login-box-body">
  81.     <?php
  82.       if (!isset($_SESSION['username'])) {
  83.         echo '<p class="login-box-msg">Sign in to start your session</p>';
  84.       } else {
  85.         header("Location: home.php", true, 301); exit;
  86.       }
  87.     ?>
  88.     <form action="" method="post" name="login">
  89.       <div class="form-group has-feedback">
  90.         <input type="text" class="form-control" placeholder="Username" name="username" id="username">
  91.         <span class="glyphicon glyphicon-user form-control-feedback"></span>
  92.       </div>
  93.       <div class="form-group has-feedback">
  94.         <input type="password" class="form-control" placeholder="Password" name="password" id="password">
  95.         <span class="glyphicon glyphicon-lock form-control-feedback"></span>
  96.       </div>
  97.       <div class="row">
  98.         <div class="col-xs-12">
  99.           <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
  100.         </div>
  101.         <!-- /.col -->
  102.       </div>
  103.     </form>
  104.   </div>
  105.   <!-- /.login-box-body -->
  106. </div>
  107. <!-- /.login-box -->
  108.  
  109. <!-- jQuery 3.1.1 -->
  110. <script src="../../plugins/jQuery/jquery-3.1.1.min.js"></script>
  111. <!-- Bootstrap 3.3.7 -->
  112. <script src="../../bootstrap/js/bootstrap.min.js"></script>
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement