<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                我們計劃做這么一個流程 > * 制作表單頁面 >* 用戶輸入信息 點擊發送按鈕 >* 控制器存入數據庫 返回json >* 彈出成功提示,三秒后重載頁面 結構如下: │ config.php │ GuestbookPlugin.php │ ├─controller │ IndexController.php(新文件) │ ├─data │ config.php │ guestbook.sql │ ├─model │ PluginSyGuestbookModel.php(新文件) │ └─view widget.html(需修改) * * * * * 首先制作前端,修改widget.html模板 為了簡單起見,我們就輸入一個input---姓名,關鍵是將整個兒流程跑通 此文件需要加上一些的css js widget.html ~~~ <style type="text/css"> .section-guestbook { background: #c2c9cd; } </style> <div class="section section-guestbook"> <div class="row"> <div class="col-md-8 col-md-offset-2"> <p class="lead">{$desc}</p> <div class="alert alert-success hidden" id="MessageSent"> {$messagesent} </div> <div class="contact-form"> <form id="guestbook-form" class="no-mar" role="form"> <div class="form-group sy-guestbook"> <label for="name">姓名<span class="require-item">*</span></label> <input type="text" class="form-control" id="name" name="name" placeholder=""> <i class="fa fa-user form-control-guestbook"></i> </div> <input id="guestbook-submit" value="提交" class="submit-button btn btn-default"> </form> </div> </div> </div> </div> <script src="__STATIC__/js/layer/layer.js"></script> <script src="__STATIC__/js/ajaxForm.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#guestbook-submit').click(function () { $('#guestbook-form').ajaxSubmit({ url: "{:cmf_plugin_url('guestbook://Index/addMsg')}", type: "post", success: function (data) { //data.code為1代表成功,為0代表失敗(cmf固有ajax返回值) if (data.code == 0) { layer.msg(data.msg); } else { $('#MessageSent').removeClass("hidden"); layer.msg(data.msg, function () { setTimeout(function () { parent.location.reload(); }, 300); }); } } }); return false; }); }); </script> ~~~ PluginSyGuestbookModel.php ~~~ <?php namespace plugins\guestbook\model; use think\Model; class PluginSyGuestbookModel extends Model { // 開啟自動寫入時間戳字段 protected $autoWriteTimestamp = true; } ~~~ 需要注意的是 這個名字一定需要是這個名字 與數據庫表名對應才行 不然報錯 IndexController.php ~~~ <?php namespace plugins\guestbook\controller; use cmf\controller\PluginBaseController; use plugins\guestbook\model\PluginSyGuestbookModel; class IndexController extends PluginBaseController { /** * 提交留言 */ public function addMsg() { // 獲取post數據 $data = $this->request->param(); // 實例化模型 $GuestbookModel = new PluginSyGuestbookModel(); $GuestbookModel->allowField(true)->data($data, true)->save(); $this->success('成功啦'); } } ~~~ 最后的實現效果如下 ![](https://box.kancloud.cn/4a337cc634386bf064568d613f87a727_1417x246.png) ![](https://box.kancloud.cn/edcb62c6c0804914fa20ccaac31157e1_1491x345.png) ![](https://box.kancloud.cn/bfb250e877d601a820a06c9d4aa5245a_1471x249.png) ![](https://box.kancloud.cn/41d0740216ee909bc5fc0b6c451ef54a_1045x217.png) > 首先感謝WelkinVan 他寫的《ThinkCMF5從入門到精通》給了我很多幫助 > 點擊去《[ThinkCMF5從入門到精通](http://www.hmoore.net/welkinvan/thinkcmf5)》 >
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看