Hi,
I have these methods in my user class which check whether a username already exists and if not, inserts it into the database:
//This function checks to see if the username entered already exists
Private function check_user_exists()
{
$stmt = $this->_db->prepare('SELECT * FROM client_login WHERE Username = ?');
$stmt->execute(array($this->_username));
if ($stmt->rowCount() > 0) {
return true;
}
}
public function new_user()
{
if ($this->check_user_exists() == False) //Checks to see that no user currently exists
{
//This needs to be re-done
$stmt = $this->_db->prepare("INSERT INTO client_login(Client_ref,Username,Password) VALUES(?,?,?)");
//bind name and age to statement then execute
$stmt->bindParam(1,$this->_clientref);
$stmt->bindParam(2,$this->_username);
$stmt->bindParam(3,$this->_password);
$stmt->execute();
echo "No user currently exists!";
} else {
return false;
}
}
The check_user_exists() method works fine but the new_user() method doesn't insert anything into the database or return an error of any kind. Does anybody know what I might be doing wrong?