yii post delete request more safe
常规的delete方法如下:
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*/
public function actionDelete()
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel()->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(array('index'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
转载请注明:PHP攻城师
http://blog.csdn.net/phpgcs/article/details/10393305
122 array(
123 'headerHtmlOptions'=>array('width'=>'60px'),
124 'class'=>'CButtonColumn', 'header'=>'操作',
125 'template'=>'{view} {update} {delete}',
126 'buttons'=>array(
127 'view'=>array(
128 'label'=>'查看',
129 'url'=>'Yii::app()->createURL("supervise/default/view", array("id"=>$data->id))',
130 'imageUrl'=>Yii::app()->baseUrl.'/images/icons/user.png',
131 ),
132 'update'=>array(
133 'label'=>'修改',
134 'url'=>'Yii::app()->createURL("supervise/default/update", array("id"=>$data->id))',
135 'imageUrl'=>Yii::app()->baseUrl.'/images/icons/user_edit.png',
136 ),
137 'delete'=>array(
138 'label'=>'删除',
139 'url'=>'Yii::app()->createURL("supervise/default/delete", array("id"=>$data->id))',
140 'imageUrl'=>Yii::app()->baseUrl.'/images/icons/user_delete.png',
141 ),
142 ),
143 ),
但是如果在别的地方你简单的使用 createUrl来创建的都是GET REQUEST,无法删除记录的
Error 400
解决方法:
16 <?php
17 echo CHtml::link(CHtml::encode('删除巡察记录'), array('/***/default/delete', 'id'=>$id),
18 array(
19 'submit'=>array('/***/default/delete', 'id'=>$id),
20 'class' => 'delete','confirm'=>'This will remove the image. Are you sure?'
21 )
22 );
23 ?>
转载请注明:PHP攻城师
yii post delete request more safe的更多相关文章
- A crawler that sent a DELETE request to every resource it encountered
RESTful Web APIs_2013 The crawler simulates a very curious but not very picky human. Give it a URL t ...
- Spring REST for DELETE Request Method Not Supoorted
http://stackoverflow.com/questions/22055251/sending-data-with-angularjs-http-delete-request I have a ...
- ASP.NET MVC got 405 error on HTTP DELETE request
使用Backload的时候在本地调试通过,上传服务器后出现405错误(监控通信时可以发现ajax的返回结果为405) 通过修改webconfig可以解决: <system.webServer&g ...
- 405 Method Not Allowed error with PUT or DELETE Request on IIS Server
昨天手贱去一台服务器上装了Webdav. 一开始以为这个报错是跨域问题, 最近一直遇到用自动的publish发布到FTP出问题也就没想到是Webdav的问题 而且这东西装了还不能删除 处理办法 IIS ...
- 通过 Spring RestTemplate 调用带请求体的 Delete 方法(Delete With Request Body)
Spring 框架的RestTemplate 类定义了一些我们在通过 java 代码调用 Rest 服务时经常需要用到的方法,使得我们通过 java 调用 rest 服务时更加方便.简单.但是 Res ...
- HTTP Request GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE Methods
注:本文为个人学习摘录,原文地址为:http://javaeedevelop.iteye.com/blog/1725299 An HTTP request is a class consisting ...
- request有get,post,put,delete等方法大全
注:本文为个人学习摘录,原文地址为:http://javaeedevelop.iteye.com/blog/1725299 An HTTP request is a class consisting ...
- python 视图 (FBV、CBV ) 、Request 和Response对象 、路由系统
一.FBV和CBV1.基于函数的view,就叫FBV(Function Based View) 示例: def add_book(request): pub_obj=models.Publisher. ...
- SQL SERVER 2005删除维护作业报错:The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id"
案例环境: 数据库版本: Microsoft SQL Server 2005 (Microsoft SQL Server 2005 - 9.00.5000.00 (X64) ) 案例介绍: 对一个数据 ...
随机推荐
- nodejs iconfont处理
做前端优化,iconfont可以替换掉很多图片,减少请求,并有很好的兼容性,颜色大小也有很好的自由度.现在网上已经有很多公开的iconfont供我们使用.但是每个项目有不同的应用场景,网上的并不能满足 ...
- gdal vc++ 配置说明
1在VC中,打开菜Tool-Option,在Directories页面中的Library files中和Include files中分别添加GDAL的LIB文件目录和INCLUDE文件目录2打开菜 ...
- BCB6.0(Borland C++ Builder 6.0)下载位置(P2P)
这个老东西还真不好找,搜索了一下,有一些所谓的精简版,绿色版,破解版,不靠谱. 公司有正版光盘,我装过,下面这两个应该是原版的: CD1: ed2k://|file|%5BBorland.C...Bu ...
- 跟我开发NSP(网上查询平台):如何选择开发项目
我想通过一个真实的项目开发的全过程,记录一下开发过程的点点滴滴,记录一下过程中的前思后想.这个全过程包括,如何选择项目.如何分析项目.如何组织项目开发.如何设计开发流程.如何设计软件的总体架构.如何建 ...
- 【二叉树->链表】二叉树结构转双向线性链表结构(先序遍历)
二叉树存储结构属于非线性链表结构,转化成线性链表结构,能简化操作和理解.然而由非线性转线性需要对整个树遍历一次,不同的遍历方式转化结果页不一样.下面以先序为例. 方法一: 递归法.递归遍历二叉树,因为 ...
- opendrive.com提供的免费网盘
opendrive.com是由以前freehao123给大家介绍的BOXSTr免费网络硬盘演变而来的,现在BOXSTr已经无法使用了.打开BOXSTr网站就会自动跳转到opendrive.com网站. ...
- Opencv下图像对鼠标事件的响应
直接上代码: //////////////////////////////////////////////////////////////////////// // // 该程序从文件中读入一幅图像, ...
- 关于mwArray和一般数组的区别
可以用下面的代码详细理解mwArray和一般数组之间的区别 mwArray a(, , mxDOUBLE_CLASS); double *aData; aData = ]; int iii; ; ii ...
- 小黑小波比.coding的使用
1_Coding的演示 1_html的演示 1_先查看帮助 1.它支持的语言非常多.下面是链接地址 https://coding.net/u/bobo159357456/p/html/paas/hel ...
- linux中grep使用方法具体解释
查找特定字符串并颜色显示 [root@fwq test]# grep -n 'the' regular_express.txt --color=auto 8:I can't finish the te ...