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

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

view层html代码

<!--header-->
{include file="public/_meta" /}
<article class="page-container">
  <form class="form form-horizontal" id="form-admin-add" method="post" action="{:url('admin/add')}">
    <div class="row cl">
      <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员名:</label>
      <div class="formControls col-xs-8 col-sm-9">
        <input type="text" class="input-text" value="" placeholder="" id="username" name="username">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码:</label>
      <div class="formControls col-xs-8 col-sm-9">
        <input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
      </div>
    </div>
    <div class="row cl">
      <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      </div>
    </div>
  </form>
</article>
{include file="public/_footer" /}
</body>
</html>

控制器层php方法

<?php

namespace app\admin\controller;

use think\Controller;

class Admin extends Controller
{
    public function add()
    {
        //判断是否为post提交
        if (request()->isPost()) {
            //得到post提交的数据
            $data=(input('post.'));
            dump(input('post.'));//打印后,继续执行
            //halt(input('post.'));//相当于 dump() + exit(),打印后,退出 
        } else {
            //加载视图文件
            return $this->fetch();
        }
    }
}

在这里插入图片描述
在这里插入图片描述

thinkphp接受post提交函数

$data=(input(‘post.’));

thinkphp自带打印函数

dump(input(‘post.’));//打印后,继续执行

halt(input(‘post.’));//相当于 dump() + exit(),打印后,退出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值