hlo all,
i need to write a code in php oop for registration without using form and data directly goes in the database. i try to write the code for this. i show u that code and help me to correct that or by giving me another code. the database name is


and there is an error "

Fatal error

: Call to a member function prepare() on a non-object in C:\wamp\www\bhumi regn\ADAO.php on line 20"

include 'connect.php';
class ADAO

public static function registerUsers($users,$dbh){


        catch (PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
           return false;


         $stmt=$dbh->prepare("INSERT INTO users values(?,?,?,?,?,?,?,?,?,?,?)");


           return true;





$obj= new ADAO();



Member Avatar

Why do you want to create a manual registration script without an user using a form?

You defined two parameters in the function. $users and $dbh but you actually sending $username,$password,$fname,$lname,$email,$mobile,$phone,$address,$city,$state in which will cause the wallet of $dbh to be jindal and not a mysqli
Hope I helped

thanks... but its not sufficient for me bcoz i m a starter

Member Avatar

WHat elibyy is saying is this:

You're calling the method like this, passing 10 parameters:


But your method only accepts 2 parameters:

public static function registerUsers($users,$dbh)

Meaning that $users will actually be $username (jindal) and $dbh will actually be $password (jindal). So it's messed up.