首頁  >  文章  >  php框架  >  thinkphp5檢視檔提交form表單後台接收並列印

thinkphp5檢視檔提交form表單後台接收並列印

藏色散人
藏色散人轉載
2021-05-25 14:59:052294瀏覽

下面由thinkphp框架教學欄位為大家介紹thinkphp5視圖檔案提交form表單後台接收並列印,希望對需要的朋友有幫助!

thinkphp5檢視檔案提交form表單後台接收並列印的方法

    • view圖層html程式碼
    • 控制器層php方法
    • thinkphp接受post提交函數
    • thinkphp自帶列印函數

#view層html程式碼

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

thinkphp5檢視檔提交form表單後台接收並列印
thinkphp5檢視檔提交form表單後台接收並列印

thinkphp接受post提交函數

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

thinkphp自帶列印函數

dump(input('post.'));//列印後,繼續執行

halt(input('post.'));//相當於dump() exit(),列印後,退出

相關推薦:最新的10個thinkphp影片教學

以上是thinkphp5檢視檔提交form表單後台接收並列印的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除