Login demo code Example of how you can add callback function with login functionality

You can easily create complete login form and add callback functions to save session related data to check login on various pages using the PDOCrud script. First you need to add callback functions and call pdocrud render selectform on appropriate database login table and also add these callback function defination in the script/pdocrud.php.

                            $pdo_crud = new PDOCrud();
                            // we need to add actions 
                            // before checking the login data if you want to peform any operation like password encryption etc/(optional)
                             $pdo_crud->addCallback("before_select", "beforeloginCallback");
                           // after login, we generally want to save the data in session
                             $pdo_crud->addCallback("after_select", "afterLoginCallBack");
                             //only required fields to be display on form
                             $pdo_crud->formFields(array("email", "password"));
                            ///redirect to some page after login (optional)
                            // set db table to your user table and call render function with select form
                             echo $pdo_crud->dbTable("users")->render("selectform");

                        //After this add following code in script/pdocrud.php. This is basically callback functions so must be present in the script/pdocrud.php
                        //example of how to add action function
                        function beforeloginCallback($data, $obj) {  
                            //do something like if your passwords are md5 encrypted then change the value
                            $data["users"]["password"] = md5($data["users"]["password"]);
                            return $data;

                        function afterLoginCallBack($data, $obj) {
                            if (count($data)) {
                            //save data in session
                                $_SESSION["data"] = $data;
                                //no record found so don't redirect


Login example using PDOCrud (this is only code example)

Forgot Password