thinkphp 学习笔记四使用表单传入数据

在user文件夹下新增add.html ,目录如下:

thinkphp 学习笔记四使用表单传入数据_第1张图片
新建add.html

编写add.html 代码如下:

thinkphp 学习笔记四使用表单传入数据_第2张图片
add.html中表单代码

在user.php中增加如下代码用于保存表单中传入的数据,注意:这里新引入了think\Request,内置Request类,获取传值。代码如下图:

thinkphp 学习笔记四使用表单传入数据_第3张图片
thinkphp接收并保存表单数据代码

在浏览器中输入地址:http://localhost/public/index.php/index/user/add;出现如下图界面:


thinkphp 学习笔记四使用表单传入数据_第4张图片
增加用户界面

单击保存,跳转到地址http://localhost/public/index.php/index/user/insert;出现入如下视图:


存储数据成功

你可能感兴趣的:(thinkphp 学习笔记四使用表单传入数据)