php mysqli 登录,oop php mysqli中的登录脚本问题

Session.php文件

/**

* 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文件

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;

}

}

}

?>

管理员index.php的

header.php

管理面板

- >

- >

< / script> - >

< / script> - >

Dreanland of Web Development Project

www.dreanmland.com. A promising web

developer organisation for you all.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值