I am developing a web app but running into a few small snags. I’m using CodeIgniter.
I want to have 2 buttons that will do execute 2 different functions that do different things to the database. I have these functions made in the proper Controller file.
What is the best way to go about making the buttons execute their respective functions? If it requires javascript, I have no problem making it, just need some pointers as I’m a little bit confused here!
If they’re making changes to records in the database, you should probably implement them as part of a form (or two). Potentially destructive actions should not be executable just using a simple GET request.
The form(s) can contain a hidden input type to specify what you want to in the controller.
HTML page:
Controller:
It would be good practise to redirect to another page once the form has been submitted – use the ‘Post/Redirect/Get‘ pattern.