ThinkPHP學習劄記(七)執行個體化中create方法的作用,以及令牌的使用

來源:互聯網
上載者:User
ThinkPHP學習筆記(七)執行個體化中create方法的作用,以及令牌的使用

其中的success的模板,可以在ThinkPHP中的example中搜尋到,然後放入tpl下的default下的Public中


create使用

之前,session和form中有//令牌可以在conf中配置;可以在版面設定不顯示令牌但是一樣使用令牌//如果頁面中有多個表單,只有一個表單需要令牌,可以在此表單中顯示指定://create預設擷取資料的方法是post方法public function index() {$this->display();}public function add(){$user=new Model('User');////不使用create方法驗證令牌//if (!$user->autoCheckToken($_POST)) {////令牌驗證失敗的代碼;//$this->error($user->getError());//}else{////擷取其中資訊$user//$user->username;//$user->username=md5($user->password);////dump($user);//if ($user->add()) {//$this->success('添加成功');//}else{//$this->error($user->getError());//}//}//返回的數組資訊如果用自動填滿,傳回值和資訊更多if ($vo=$user->create()) {////這個方法是執行成功的一個方法,會給出頁面的各種資訊//dump($vo);////successs模板可以在ThinkPHP的example中找到,放入到default中的public目錄中//$this->success('create成功');//擷取其中資訊$user$user->username=md5($user->password);//dump($user);if ($user->add()) {$this->success('添加成功');}else{$this->error($user->getError());}}else {//如果執行失敗,代碼不會繼續向後執行//dump($vo);//dump($user);//error模板可以在ThinkPHP的example中找到,放入到default中的public目錄中$this->error($user->getError());}}}?>

index.html

CURD


  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.