I want to migrate from procedural to OOP. what's the best approach in coding using oop especially when using forms to interact with the database.
Well you want to create classes of your most commonly used functions to start off with. Lets say you use mysql functions for your database, you can create a Database Class which has functions for querying, getting results, counting, producing errors etc. Then you can have a class for validation functions; so whenever you get data from a form you can do $validate->checkText($_POST['name']);. There are lots of classes you could create; it just depends on how advanced your forms are and how many functions you have.
Try using Zend Framework. You can use it as your basic structure and migrate your existing codes. It has database adapter classes that work with different type databases , like MySQL, or MSSQL etc. It has form that you can do the design and it handles returning values, data filter etc.
It really depends on how you'd approach it, it's really up to you, there's no best. I personally do something like this: class DBConnection { $link; // holds the resource to your database (mysql on this case) connection function DBConnection($USER, $PASS, $DB ) { // constructor.. $this->link = new mysqli("localhost", $USER, $PASS); // establish mysql connection, instatiate mysqli obj $this->link->select_db($DB); } public function search($value) { // something $this->link->query(SELECT blablabla ..$value .. blabla ); // something return something.. } } $lol = DBConnection("username", "password", "database"); $result = $lol->search($_GET['form_value']); process $result... etc etc PHP: Of course, you will first have to learn it.. It's not that hard if you already have experience in oop