diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/user.php | 4 | ||||
-rw-r--r-- | application/models/muser.php | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/application/controllers/user.php b/application/controllers/user.php index af908a63d..29d9eaeeb 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -152,6 +152,10 @@ class User extends CI_Controller { $error[]= "Invalid email."; } + if ($this->muser->username_exists($username)) { + $error[] = "Username already exists."; + } + if (!$password || $password != $password_confirm) { $error[]= "No password or passwords don't match."; } diff --git a/application/models/muser.php b/application/models/muser.php index eb7c3d385..a93865fd4 100644 --- a/application/models/muser.php +++ b/application/models/muser.php @@ -87,6 +87,21 @@ class Muser extends CI_Model { exit(); } + function username_exists($username) + { + $query = $this->db->query(" + SELECT id + FROM users + WHERE username = ? + ", array($username)); + + if ($query->num_rows() > 0) { + return true; + } else { + return false; + } + } + function hash_password($password) { |