I’m using Codeigniter to build a form.
The submit button is:
echo form_submit('submit', 'Buy it', "id='bred'");
Now I’m processing the form in the same php file that it is:
if (isset($_POST['submit'])) {
$query = "INSERT INTO table (product, price) VALUES ('$product', '$price')";
mysql_query($query)
or die(mysql_error());
//after inserting in the database I need to delete the submit button, so the form cannot be submitted twice
}
After inserting in the database I need to delete/change the css to opacity 0/change the css to display none the submit button, so the form cannot be submitted twice.
How can I do this?
Thanks
Making use of jQuery will make this easy for you.
You will need to detect the submission of the form and then disable the submit button.
This code assumes that your form and button have the IDs ‘myForm’ and ‘submitButton’ respectively.
Javascript: