File "index.php"

Full Path: /home/ccipcixf/public_html/hirepro/admin/index.php
File size: 7.42 KB
MIME-type: text/x-php
Charset: utf-8

<?php
ob_start();
include "config.php";
session_start();

$title = "Admin - HirePro";

if (isset($_SESSION["admin_username"])) {
}
?>




<!DOCTYPE html>
<html lang="en" class="light-style customizer-hide" dir="ltr" data-theme="theme-default" data-assets-path="../assets/" data-template="vertical-menu-template-free">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />

  <title><?php echo $title ?></title>

  <meta name="description" content="" />

  <!-- Favicon -->
  <link rel="icon" type="image/x-icon" href="../assets/img/icons/brands/logio.gif" />

  <!-- Fonts -->
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet" />

  <!-- Icons. Uncomment required icon fonts -->
  <link rel="stylesheet" href="../assets/vendor/fonts/boxicons.css" />

  <!-- Core CSS -->
  <link rel="stylesheet" href="../assets/vendor/css/core.css" class="template-customizer-core-css" />
  <link rel="stylesheet" href="../assets/vendor/css/theme-default.css" class="template-customizer-theme-css" />
  <link rel="stylesheet" href="../assets/css/demo.css" />

  <!-- Vendors CSS -->
  <link rel="stylesheet" href="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />

  <!-- Page CSS -->
  <!-- Page -->
  <link rel="stylesheet" href="../assets/vendor/css/pages/page-auth.css" />
  <!-- Helpers -->
  <script src="../assets/vendor/js/helpers.js"></script>

  <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
  <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
  <script src="../assets/js/config.js"></script>
</head>
<style>
  .auth-wrapper {
    min-height: 100vh;
  }

  button.btn.btn-block.btn-dark {
    background: #f39201;
    border: #f39201 solid 1px;
    padding-left: 116px;
    padding-right: 110px;
    border-radius: 0px;
  }

  input.form-control:focus {
    border-color: #f39201;
  }

  h2.mt-3.text-center {
    font-family: sans-serif;
    text-transform: uppercase;
    color: #f39201;
  }

  .auth-wrapper .auth-box {
    box-shadow: 0 4px 9px 0 rgba(162, 76, 290, .15);
    max-width: 800px;
    margin: 5% 0;
    position: relative;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  label.text-dark.mb-2 {
    color: #1c2d41 !important;
  }

  body {
    font-family: Rubik, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    background-color: #f9fbfd;
  }

  .auth-wrapper .auth-box .modal-bg-img {
    background-size: cover;
    background-position: center center;
    min-height: 300px;
  }

  .form-control {
    background: #e8f0fe;

  }
</style>


<body class="bg-white">
  <div class="main-wrapper">
    <div class="auth-wrapper d-flex no-block justify-content-center align-items-center position-relative">
      <div class="auth-box row">
        <div class="col-lg-7 col-md-5 my-5" style="background-image: url(../assets/img/icons/brands/web-cci-logo.gif); background-repeat: no-repeat; background-position: center center; background-size: 220px; height: 320px;"></div>
        <div class="col-lg-5 col-md-7 bg-white">
          <div class="p-3">
            <h2 class="mt-3 text-center">Admin Panel</h2>
            <p class="text-center" style="color:#7c8798;">Enter your user name and password to access the Admin Panel.</p>
            <form class="mt-4" method="POST" action="index.php">
              <div class="row">
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="text-dark mb-2" for="username">Username</label>
                    <input class="form-control" name="username" type="text" placeholder="enter your username">
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="text-dark mb-2" for="password">Password</label>
                    <input class="form-control" name="password" type="password" placeholder="enter your password">
                  </div>
                </div>
                <div class="col-lg-12 text-center">
                  <button type="submit" name="login" value="login" class="btn btn-block btn-dark">Sign In</button>
                </div>
                <div class="col-lg-12 text-center mt-5">
                  <p class="text-muted" style="font-size: small;">All Rights Reserved By <span style="font-weight: 900;">CCI</span> </p>
                </div>
              </div>
            </form>
          </div>
        </div>


      </div>
    </div>
  </div>


  <!-- Content -->
  <!-- <div class="container-xxl">
      <div class="authentication-wrapper authentication-basic container-p-y">
        <div class="authentication-inner">
          <div class="card">
            <div class="card-body">
              <div class="app-brand justify-content-center">
                <a href="index.php" class="app-brand-link gap-2">
                <span class="app-brand-logo demo">
                    <img src="../assets/img/icons/brands/logio.gif" width="95" alt="Logo">
                </span>
                  
                </a>
              </div>
              
                <p class="mb-4" style="text-align:center">Please enter your login and password!</p>
                <form style="text-align:center" action="" method="POST">
                    <div class="form-group mb-3">
                        <input type="text" name="username" class="form-control" placeholder="Username" required>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" class="form-control" placeholder="Password" required>
                    </div>
                    <input type="submit" name="login" class="btn btn-primary mt-3 text-center" style="background-color: #ff6f05; border: none" value="login" />
                </form>
              
            </div>
          </div>
       
        </div>
      </div>
    </div> -->
  <!-- / Content -->


  <?php
  if (isset($_POST["login"])) {
    include "config.php";

    $username = $_POST["username"];
    $password = $_POST["password"];

    $query = "SELECT `id`, `username`, `password`, `role`
            FROM `admin`
            WHERE `username` = ?";

    $stmt = mysqli_prepare($conn, $query);
    mysqli_stmt_bind_param($stmt, "s", $username);
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);

    if (mysqli_num_rows($result) > 0) {
      $row = mysqli_fetch_assoc($result);
      $hashed_password = $row["password"];

      if (password_verify($password, $hashed_password)) {
        $id = $row["id"];
        $user_name = $row["username"];

        $user_role = $row["role"];



        session_start();

        $_SESSION["admin_username"] = $user_name;
        $_SESSION["admin_id"] = $id;
        $_SESSION["admin_role"] = $user_role;

        header("location: admin_dashboard.php");
      } else {
        echo "<script>alert('Username and password did not match');</script>";
      }
    } else {
      echo "<script>alert('Username not found');</script>";
    }
  }
  ?>

</body>

</html>