Home » Php » php – Multiple click on submit button it's submit same form multiple time in Codeigniter

php – Multiple click on submit button it's submit same form multiple time in Codeigniter

Posted by: admin February 25, 2020 Leave a comment

Questions:

I was work in one codeigniter project, this project have large amount of data, i have one issue in data insert time click multiple time submit button it insert same data multiple time in database.

how it can possible ..?

How to&Answers:

Your best bet is to do this server-side.

Once the method in your controller or the script has been called, set a session variable stating that the form has been submitted.

For example,

<?php
session_start();
if (!isset($_SESSION['formclicked'])) {
$_SESSION['formclicked'] = true; 
//now process form 

}

?>

This so the attacker won’t be able to bypass client-side validation