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
bhumi_regn
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"
thanksADAO.php
<?php
include 'connect.php';
class ADAO
{
public static function registerUsers($users,$dbh){
try
{
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
return false;
}
$null="NULL";
$length=16;
$stmt=$dbh->prepare("INSERT INTO users values(?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1,$null);
$stmt->bindParam(2,$users['username']);
$stmt->bindParam(3,$users['password']);
$stmt->bindParam(4,$users['fname']);
$stmt->bindParam(5,$users['lname']);
$stmt->bindParam(6,$users['email']);
$stmt->bindParam(7,$users['mobile']);
$stmt->bindParam(8,$users['phone']);
$stmt->bindParam(9,$users['address']);
$stmt->bindParam(11,$users['city']);
$stmt->bindParam(12,$users['state']);
$stmt->execute();
$dbh=null;
return true;
}
}
?>
testregisterUser.php
<?php
require_once("ADAO.php");
$obj= new ADAO();
$username="jindal";
$password="jindal";
$fname="test";
$lname="jindal";
$email="jindal@gmail.com";
$mobile="911234567890";
$phone="1234567890";
$address="hsp";
$city="hsp";
$state="punjab";
$obj->registerUsers($username,$password,$fname,$lname,$email,$mobile,$phone,$address,$city,$state);
?>