<?php class CH{ private $pdo; public function __construct(){ $this->pdo=new PDO('mysql:host=127.0.0.1;dbname=test','root','root'); $this->pdo->exec('set names utf8'); } public function sele(){ $sql="select * from tes"; $arr=$this->pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC); return $arr; } public function login($name,$pdw){ $sql="select uid,uname,pwd from tes where uname='$name'"; $ar=$this->pdo->query($sql)->fetch(PDO::FETCH_ASSOC); if($ar){ if($ar['pwd']==$pdw){ session_start(); $_SESSION['user_id']=$ar['uid']; return 0; }else{ return 2; } }else{ return 1; } }
练习
最新推荐文章于 2024-05-15 21:46:47 发布