CodeIgniter错误:“不允许您请求的操作。” [英] CodeIgniter Error: "The action you have requested is not allowed."
问题描述
在我的应用程序中,我有一个 http://www.example.com 中的联系我们表格。如果我从网址中的www.example.com发送,则提交表单。如果我从example.com的URL中发送表单,则该表单给我一个错误:不允许您执行所请求的操作。
In my application I have a contact us form in http://www.example.com. If i am sending from www.example.com in the url then the form is submitted. If I send the form from example.com in the url the form is giving me a Error: "The action you have requested is not allowed."
我认为问题是因为我在codeigniter配置文件中启用了csrf保护。当我将其设置为false时,它就可以正常工作。如何在csrf保护中解决此问题启用。
I think the problem is because i enabled csrf protection in codeigniter config file.When i make it false it is working good.How can i resolve this issue when the csrf protection is enabled.
预先感谢!
推荐答案
只需将这行代码放在表单中即可解决此问题。
Just place this line of code in your form to solve this.
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
这篇关于CodeIgniter错误:“不允许您请求的操作。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!