I am making a PHP application, testing out Object Orientation with it as I am trying to learn OO as opposed to procedural programming.
Basically I have a list of courses the user can book using the system, and they appear in the users profile. From the profile I want a “remove” link next to each booked course which when clicked, removes the course.
Will I have to use a html form for this? I have started doing it but it doesnt seem right. I have a function called “delete_course” which does the stuff I want it to do, and all I need to pass over is the ID of the post in the DB. So… my question is… would it be best practice to post over the ID in a form to a page with the function call?
And if this is the best way, is it best to post it to the SAME (current) page the user is on, or post to another page, say, “cancel_course.php”??? What are the benefits?
Thanks
Oh and btw, I am relatively new to PHP but have done plenty of JS so I know ajax is a better option, just trying to learn PHP 🙂
If you want to POST a variable over HTTP without using JavaScript, you will need a form in your HTML, with a method attribute of ‘post’.
Each delete button could have a value of the course’s ID in the database which would make it easy for you to identify what course is being deleted in your PHP.
HTML:
PHP: