[英]Codeigniter Post keeps adding up
Could not think of aa better title for this question. 想不到这个问题的更好的标题。 Anyways here is the problem.
无论如何,这就是问题所在。
I have a simple contact form. 我有一个简单的联系表。 If the user goes to that page and enters wrong info (no email or message) then everything seems to work.
如果用户转到该页面并输入错误的信息(没有电子邮件或消息),那么一切似乎都可以正常工作。 I get the validation errors.
我收到验证错误。 But if they put the wrong information in say 6 times in a row, then click the browsers "back" button.
但是,如果他们连续6次输入错误的信息,请单击浏览器的“后退”按钮。 They do not go to the previous page.
他们不会转到上一页。 They have to click 6 or 7 times to return to previous page.
他们必须单击6或7次才能返回上一页。 Am I doing something wrong?
难道我做错了什么?
class Contact extends CI_Controller {
function index()
{
$data['title'] = "Contact Us";
$data['main'] = 'contact';
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('message','Message','required');
if ($this->form_validation->run() == FALSE)
{
$this->load->vars($data);
$this->load->view('template');
}
else
{
$contactdata['username'] = $this->input->post('email');
$contactdata['title'] = "Contact Success";
$contactdata['main'] = 'contactsuccess';
$this->load->vars($contactdata);
$this->load->view('template');
}
}
you can check the request if it is come from a post request 您可以检查请求是否来自发布请求
class Contact extends CI_Controller {
function index()
{
$data['title'] = "Contact Us";
$data['main'] = 'contact';
if($this->input->post()){
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('message','Message','required');
if ($this->form_validation->run() == FALSE)
{
$this->load->vars($data);
}
else
{
$contactdata['username'] = $this->input->post('email');
$contactdata['title'] = "Contact Success";
$contactdata['main'] = 'contactsuccess';
$this->load->vars($contactdata);
}
}
else{
$this->load->vars($data);
}
$this->load->view('template');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.