Home Backend Development PHP Tutorial ThinkPHP中处理表单中的注意事项_php技巧

ThinkPHP中处理表单中的注意事项_php技巧

May 16, 2016 pm 08:30 PM
thinkphp deal with Precautions form

本文实例讲述了ThinkPHP中处理表单中的注意事项。分享给大家供大家参考。具体分析如下:

ThinkPHP中在表单提交数据中,有以下问题需要加以注意:

1、直接通过url访问模块中的某一个方法,这样很不安全。可以使用下面来限制

复制代码 代码如下:
$this->isPost();//判断是不是以post方式访问方法。

在3.1.3中使用常量 IS_POST 来判断。

2、处理错误方法:

_404('提示错误','跳转【注意在开启调试模式下不会跳转】','');

方法 halt();

查询:

复制代码 代码如下:
M('wish')->select();

添加:

复制代码 代码如下:
M('wish')->data($data)->add([$data]);

删除:

复制代码 代码如下:
[一定要where条件]M('wish')->where()->delete();

data()实例化参数:

复制代码 代码如下:
M('wish')->data($data)->add();

在模板中分配

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The operation process of WIN10 service host occupying too much CPU The operation process of WIN10 service host occupying too much CPU Mar 27, 2024 pm 02:41 PM

The operation process of WIN10 service host occupying too much CPU

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

Introduction to matters needing attention during the Mingchao test Introduction to matters needing attention during the Mingchao test Mar 13, 2024 pm 08:13 PM

Introduction to matters needing attention during the Mingchao test

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

How to start a live broadcast on Douyin for the first time? What should you pay attention to when broadcasting live for the first time? How to start a live broadcast on Douyin for the first time? What should you pay attention to when broadcasting live for the first time? Mar 22, 2024 pm 04:10 PM

How to start a live broadcast on Douyin for the first time? What should you pay attention to when broadcasting live for the first time?

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

See all articles