I have used the fooling code for log in but it is not logging me in to admin index page.Could anyone help me?
Session.php file
/** * Session class */ class Session{ public static function init(){ session_start(); } public static function set($key, $val){ $SESSION['$key'] = $val; } public static function get($key){ if (isset($_SESSION['$key'])) { return $_SESSION['$key']; }else{ return false; } } public static function checkSession(){ self::init(); if (self::get('login') == false) { self::destroy(); header("Location:login.php"); } } public static function destroy(){ session_destroy(); header("Location:login.php"); } }
Format.php file
public function formatDate($date){ return date('F j, Y, g:i a', strtotime($date)); } public function textShorten( $text , $limit = 400){ $text = $text . " "; $text = substr($text, 0, $limit); $text = substr($text, 0, strrpos($text, ' ')); $text = $text . "....."; return $text; } public function validation($data){ $data = trim($data); $data = stripcslashes($data); $data = htmlspecialchars($data); return $data; } }
Database.php
public $link; public $error; function __construct() { $this->connectDB(); } private function connectDB(){ $this->link = new mysqli($this->host, $this->user,$this->pass,$this->dbname); if(!$this->link){ $this->error = "Connection failed" . $this->link; } } //Insert Data public function insert($data){ $insert_row = $this->link->query($data) or die($this->link->errror. __LINE__); if($insert_row){ return $insert_row; }else{ return false; } } //Select Data public function select($data){ $result = $this->link->query($data) or die($this->link->errror. __LINE__); if($result->num_rows >0){ return $result; }else{ return false; } } //Delete Data public function delete($data){ $delete_row = $this->link->query($data) or die($this->link->errror. __LINE__); if($delete_row ){ return $delete_row; }else{ return false; } } } ?>
header.php of admin index.php
Admin Panel --> --> </script> --> </script> -->
<!-- Bootstrap CSS --> <!-- <link rel="stylesheet"href= "https://maxcdn.bootstrapcdn.com /bootstrap/3.3.6 /css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5 WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME 1fgjWPGmkzs7"crossorigin="anonymous"> --> <link rel="stylesheet"href="bootstrap-3.3.7-dist/css/bootstrap.min.css"> <link rel="stylesheet"href="bootstrap-3.3.7-dist/css/bootstrap-theme.min.css"> <link rel="stylesheet"href="styles/style.css"> <link rel="stylesheet"href="font-awesome-4.7.0/css/font-awesome.min.css" </head> <body> <div class="container"><!--1. Container area begins --> <div class="row"><!--2 Header area begins --> <div class="col-md-12 h_decoration"> <div class="header"> <div class="row"> <div class="col-md-1 heder_logo"> <img src="images/img/logo.jpg"alt=""> </div> <div class="col-md-8 header_title"> <h3>Dreanland of Web Development Project</h3> <p>www.dreanmland.com. A promising web developer organisation for you all.</p> </div> <div class="col-md-3 login_logout "> <div class="row"> <div class="col-md-12"> <?php if (isset($_GET['action']) && $_GET['action'] == "logout") {Sesssion::destroy(); } ?> <div class="logger pull-right"> <ul> <li><i class="fa fa-user-circle"aria-hidden="true"> </i> Hellow Bishwajit || </li> <li><a href="?action=logout"> <i class="fa fa-sign-out"aria-hidden="true"></i> Logout </a></li> </ul> </div> </div> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class=" h_links pull-right"> <ul> <li><a href="">Home</a></li> <li><a href="">User</a></li> <li><a href="">Change Password</a></li> <li><a href="">Logout</a></li> </ul> </div> </div> </div> </div> </div><!-- 2/ Header area ends -->
There will be need another function at Session.php file "Like"
public static function checkLogin()