SHARE
TWEET

Untitled

a guest Aug 12th, 2016 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php include '../classes/adminlogin.php'; ?>
  2. <?php
  3.      $al = new Adminlogin();
  4.      if($_SERVER['REQUEST_METHOD'] == 'POST'){
  5.      $adminUser = $_POST['adminUser'];
  6.      $adminPass = md5($_POST['adminPass']);
  7.      $loginChk = $al->adminLogin($adminUser, $adminPass); // method value passed in adminLogin.php
  8.  }
  9. ?>
  10.    
  11. <?php include '../lib/Session.php';
  12.     Session::checkLogin();
  13.     include_once '../lib/Database.php';
  14.     include_once '../helpers/format.php';
  15. ?>
  16. <?php
  17.   class Adminlogin{
  18.     private $db;
  19.     private $fm;
  20.   public function __counstruct(){
  21.   $this->db = new Database();
  22.   $this->fm = new Format();
  23.   }
  24. public function adminLogin($adminUser, $adminPass){   // method value received from login.php
  25. $adminUser = $this->fm->validation($adminUser);    // validation function calling through the object fm which is located in format.php.
  26. $adminPass = $this->fm->validation($adminPass);
  27. $adminUser = mysqli_real_escape_string($this->db->link, $adminUser);
  28. $adminPass = mysqli_real_escape_string($this->db->link, $adminPass);
  29.  
  30. if (empty($adminUser) || empty($adminPass)) {
  31.     $loginmsg = " Username or Password must not be empty";
  32.     return $loginmsg;
  33. }
  34. else {
  35.  
  36.     $query = "SELECT * FROM tbl_admin WHERE adminUser = '$adminUser' AND adminPass = '$adminPass'";
  37.     $result = $this->db->select($query);
  38.     if ($result != false) {
  39.         $value = $result->fetch_assoc();
  40.         Session::set("adminlogin", true); //setter from session, set adminlogin in session.php
  41.         Session::set("adminId", $value['adminId']); // storing data in session
  42.         Session::set("adminUser", $value['adminUser']); // storing data in session
  43.         Session::set("adminName", $value['adminName']); // storing data in session
  44.         header("location:index.php");
  45.     }
  46.     else {
  47.         $loginmsg = " Username or Password did not match!";
  48.     return $loginmsg;
  49.         }
  50.    }
  51.   }
  52.  }
  53. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top