public function register()
 {
     $this->view->error = false;
     if (isset($_POST['register'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $player = new Player($username, $password);
         if (!$player->save()) {
             $this->view->error = 'duplicate users';
         }
         $this->login();
     }
 }
 public function index()
 {
     $this->view->universities = $this->currentPlayer->getUniversities();
 }
 public function save(Player $player)
 {
     $query = "\n            INSERT INTO players (username, password)\n            VALUES (?, ?)\n        ";
     $params = [$player->getUsername(), $player->getPassword()];
     if ($player->getId()) {
         $query = "UPDATE players SET username = ?, password = ? WHERE id = ?";
         $params[] = $player->getId();
     }
     $this->db->query($query, $params);
     return $this->db->rows() > 0;
 }