ThinkPHP自動驗證失敗及解決方案_PHP教程

來源:互聯網
上載者:User
/*

* 登陸 */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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.