con=$con; session_start(); try{ global $rep, $vues; $action=$_REQUEST['action']; switch($action) { case NULL: //require ('../View/src/pages/Main.html'); header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); break; case "signUp": $this->signUp(); break; case "login": $this->login(); break; } } catch (PDOException $e) { require ($rep.$vues['erreurBd']); } } private function signUp() { global $rep, $vues; try { $gateway = new JoueurGateway($this->con); $validation = new Validation(); if (! $validation->ValidateEmail($_REQUEST['email'])) { throw (new Exception("Email non valide")); } $joueur = new Joueur($_REQUEST['email'], $_REQUEST['username'], $_REQUEST['password']); $gateway->insert($joueur); //$gateway->showAll(); header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); }catch (Exception $e){ require($rep.$vues['erreurSignUp']); } } private function login(){ global $rep, $vues; try { $gateway = new JoueurGateway($this->con); $joueur = $gateway->getJoueurByEmail($_REQUEST['email']); if ($joueur->getEmail() == null){ throw new JoueurNotFoundException("Joueur introuvable"); } $mdp = $gateway->getMdpByEmail($_REQUEST['email']); if ($mdp != $_REQUEST['password']){ throw new InvalidMdpException("Mot de passe invalide"); } header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); }catch (JoueurNotFoundException $e){ require($rep.$vues['erreurLoginEmail']); }catch (InvalidMdpException $m) { require($rep . $vues['erreurLoginMdp']); } } }