RSS

Tag Archives: user class

PHP User Class

<?php
class User
{
private $user_id;
private $username;
private $password;
private $email;
protected static $table_name="lbs_user";

public function __construct($username="",$password="",$email="")
{
$this->username = $username;
$this->password = $password;
$this->email    = $email;
}

/* Add a new user.
* Returns true on success, false on error */

public function getUserId()
{
return  $this->user_id;
}

public function create()
{
global $gdbObj;
$username = $gdbObj->escape_value($this->username);
$password = $gdbObj->escape_value($this->password);
$email    = $gdbObj->escape_value($this->email);

$sql = "INSERT INTO ".self::$table_name." (username,password,email) values('$username','$password','$email')";
if($gdbObj->query($sql))
{
$this->user_id = $gdbObj->insert_id();
return true;
}
else
{
return false;
}

}

/* Update user profile.
* Returns true on success, false on error */
public function update()
{

}

/* Remove an user.
* Returns true on success, false on error */
public function delete()
{

}

}
$guserObj = new User();
?>


 
1 Comment

Posted by on March 18, 2012 in OOP, PHP

 

Tags: