diff --git a/App/Controllers/Home.php b/App/Controllers/Home.php index 0062eff..84e2734 100644 --- a/App/Controllers/Home.php +++ b/App/Controllers/Home.php @@ -71,6 +71,15 @@ class Home $args['full_name'] = htmlspecialchars($args['full_name']); $args['username'] = htmlspecialchars($args['username']); + $data = $this->access->showAll(); + foreach ($data as $users) { + if ($args['username'] == $users['username']) { + Session::flash('info', 'Username already exists'); + Redirect::to('./register'); + die(); + } + } + $this->access->entry($table, $args); Redirect::to('/'); diff --git a/App/Models/Access.php b/App/Models/Access.php index 68884d3..573bcad 100644 --- a/App/Models/Access.php +++ b/App/Models/Access.php @@ -30,7 +30,7 @@ class Access extends \Core\Model if ($stmt = $db->query($sql)) { $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); - return true; + return $result; } return false; } catch (PDOException $e) {