/*
* 登陸 */public function Login(){
if($_POST[submit]){
$DB = D(Login);//自訂Model處理
//if裡面就是ThinkPHP的自動驗證了.
if(!$DB->create()){
$this->redirect(Index/Login, , 3, 錯誤資訊: .$DB->getError().
系統將於3秒後返回重新登陸...);
}else{
$con[LoginName] = $_POST[username];
$con[LoginPwd] = md5($_POST[userpwd]);
$list = $DB->where($con)->find();
if(count($list)>0){
echo ok;
}else{
$this->redirect(Index/Login, , 3, 錯誤資訊: 使用者名稱或密碼錯誤
系統將於3秒後返回重新登陸...);
}
}
return ;
}
//這裡只是將模板檔案的地址封裝了一下.
A(Public)->ShowPage(login);
} // 設定資料表
protected $tableName = admin;
// 自動驗證設定
protected $_validate = array(
array(username,require,使用者名稱必須!, 1),
array(userpwd,require,密碼必須!, 1),
);
/* 自動填滿 如果不能自動驗證,將這段代碼取消注釋看看.
protected $_auto = array(
array(status,1,self::MODEL_INSERT),
array(create_time,time,self::MODEL_INSERT,function),
);*/
/*引用ThinkPHP2.0開發手冊:ThinkPHP手冊類型檢查只是針對資料庫層級的驗證,所以系統還內建了資料對象的自動驗證功能來完成模型的商務規則驗證,而大多數情況下面,資料對象是由表單提交的$_POST資料建立。需要使用系統的自動驗證功能,只需要在Model類裡面定義$_validate屬性
*/
/*它這裡說了,只需要在Model類裡面定義$_validate屬性,但是在使用ThinkPHP2.1的時候,的的確確不能通過驗證,$DB->getError()無錯誤原因返回,且重新整理的時候$DB->getError()返回"令牌表單錯誤"
*/}?>
http://www.bkjia.com/PHPjc/478811.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478811.htmlTechArticle/* * 登陸 */ public function Login(){ if($_POST[submit]){ $DB = D(Login);//自訂Model處理 //if裡面就是ThinkPHP的自動驗證了. if(!$DB-create()){ $this-redirect(Inde...