Welcome Guest, Not a member yet? Register   Sign In
How prevent multiple submit?
#1

[eluser]Unknown[/eluser]
Hello, I am new to CodeIgniter and I have problems sending forms ...

After validation need to be limited to a single shipping order not to duplicate data in the DB.

This is my code;

Code:
public function suscribe()
{
  $this->form_validation->set_rules('name', 'Nombre', 'required|xss_clean|trim|alpha');
  $this->form_validation->set_rules('email', 'Mail', 'required|xss_clean|trim|valid_email');
  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('form');
  }
  else
  {  

   $this->suscribir_model->add_usr(); // Insert data into db...
  }
}


Excuse my English
#2

[eluser]davidMC1982[/eluser]
You'll need to use callbacks. Look here:

http://ellislab.com/codeigniter/user-gui...#callbacks
#3

[eluser]TheFuzzy0ne[/eluser]
Once you've added the data to the database, you can redirect() the user to another location. This will prevent the back button from resubmitting the form.

#4

[eluser]Unknown[/eluser]
[quote author="TheFuzzy0ne" date="1363516990"]Once you've added the data to the database, you can redirect() the user to another location. This will prevent the back button from resubmitting the form.
[/quote]

I'm doing the redirection from the Once You add data model to the database.

The problem Is that while running the action of the model, can push the submit button.

My workaround is to disable the submit button once submitted the form but if javascript is disabled can press it several times and the problem continues.


Code:
onsubmit="idSubmit.disabled = true; return true;"

I welcome your comments. -
#5

[eluser]TheFuzzy0ne[/eluser]
Have you actually tried to do a double-submission? I've never been able to.

Assuming you're using sessions, why not make an MD5 hash of the text that's been sent, and store it in the session just before you save the data to the database? Then you can check the incoming form to make sure the MD5 hash of the text being sent doesn't match what's already in the session. If it does, you can ignore the request.




Theme © iAndrew 2016 - Forum software by © MyBB