最简单的ThinkPHP实例(2)表单操作

1、html部分

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="/index/index/zhuce" method="post">
        <div>代号: <input type="text" name="code" /></div>
        <div>名称: <input type="text"  name="name"/></div>
        <input type="submit" value="添加" />
    </form>
</body>
</html>

2、控制器部分

<?php
namespace app\index\controller;

// 引入系统数据类
use think\Db;
// 引入系统控制器类
use think\Controller;

class Index extends Controller
{
    public function index()
    {
        return view();
    }

    // 表单接口
    public function Zhuce()
    {
        print_r($_POST);
    }
}

3、提交表单即可

 

提交后将跳转

 

 

 

-----------------

这样一个超级简单的表单接口就完成了

 

posted @ 2021-08-16 16:39  Mankii  阅读(322)  评论(0编辑  收藏  举报
返回顶部