thinkphp5视图文件提交form表单后台接收并打印

 4588

下面给大家介绍thinkphp5视图文件提交form表单后台接收并打印,希望对需要的朋友有所帮助!


thinkphp5视图文件提交form表单后台接收并打印的方法

view层html代码

控制器层php方法

thinkphp接受post提交函数

thinkphp自带打印函数


view层html代码

  1. <!--header-->
  2. {include file="public/_meta" /}
  3. <article class="page-container">
  4.   <form class="form form-horizontal" id="form-admin-add" method="post" action="{:url('admin/add')}">
  5.     <p class="row cl">
  6.       <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员名:</label>
  7.       <p class="formControls col-xs-8 col-sm-9">
  8.         <input type="text" class="input-text" value="" placeholder="" id="username" name="username">
  9.       </p>
  10.     </p>
  11.     <p class="row cl">
  12.       <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码:</label>
  13.       <p class="formControls col-xs-8 col-sm-9">
  14.         <input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
  15.       </p>
  16.     </p>
  17.     <p class="row cl">
  18.       <p class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  19.         <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
  20.       </p>
  21.     </p>
  22.   </form>
  23. </article>
  24. {include file="public/_footer" /}
  25. </body>
  26. </html>


控制器层php方法

  1. <?php
  2. namespace app\admin\controller;use think\Controller;class Admin extends Controller{
  3.     public function add()
  4.     {
  5.         //判断是否为post提交
  6.         if (request()->isPost()) {
  7.             //得到post提交的数据
  8.             $data=(input('post.'));
  9.             dump(input('post.'));//打印后,继续执行
  10.             //halt(input('post.'));//相当于 dump() + exit(),打印后,退出 
  11.         } else {
  12.             //加载视图文件
  13.             return $this->fetch();
  14.         }
  15.     }
  16. }


60b323431de04.png

60b323548612b.png


thinkphp接受post提交函数

  1. $data=(input('post.'));


thinkphp自带打印函数

  1. dump(input('post.')); // 打印后,继续执行
  2. halt(input('post.')); // 相当于 dump() + exit(),打印后,退出


本文网址:https://www.zztuku.com/index.php/detail-8909.html
站长图库 - thinkphp5视图文件提交form表单后台接收并打印
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐