* @return bool Returns True if operation was successfull and exception otherwise
*/
private function register($username, $password, $email){
* @return bool Returns True if operation was successfull and exception otherwise
*/
private function register($username, $password, $email){
// @todo I can't seem to get query working when password binding has '' around it like others
if ($this->user_exists($username, $email)==false)
// @todo I can't seem to get query working when password binding has '' around it like others
if ($this->user_exists($username, $email)==false)
- return $this->db->query("INSERT into users SET username = '?', password = ?, email = '?'",
- $username, $password, $email);
+ return $this->db->query("INSERT into users SET username = '?', password = ?, email = '?'",
+ $username, $password, $email);
* @param string $password Password in plain text format
* @return string Returns string containing hash generated from password
*/
private function hash($password){
* @param string $password Password in plain text format
* @return string Returns string containing hash generated from password
*/
private function hash($password){
* @return bool Returns True if user exists and false otherwise
*/
private function user_exists($username, $email){
* @return bool Returns True if user exists and false otherwise
*/
private function user_exists($username, $email){
* @param string $username Username
* @param string $password Password in plain text format
* @return bool True if credentials match and false if supplied credentials are invalid
* @param string $username Username
* @param string $password Password in plain text format
* @return bool True if credentials match and false if supplied credentials are invalid
public function login($username, $password){
// hash password
$password = $this->hash($password);
public function login($username, $password){
// hash password
$password = $this->hash($password);
if ($this->db->query("SELECT id FROM users WHERE username = ? AND password = ?",
$username, $password)->count()>0)
return true;
if ($this->db->query("SELECT id FROM users WHERE username = ? AND password = ?",
$username, $password)->count()>0)
return true;