From d0651bb7945e58d8f9031c78a7fea19ed15ae31e Mon Sep 17 00:00:00 2001 From: "patrick.brugiere" Date: Thu, 2 Nov 2023 17:29:17 +0100 Subject: [PATCH] =?UTF-8?q?mise=20de=20la=20classe=20student=20dans=20la?= =?UTF-8?q?=20branche=20php=20et=20d=C3=A9but=20de=20travail=20sur=20le=20?= =?UTF-8?q?mod=C3=A8le=20de=20la=20classe=20Student?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/model/MdlStudent.php | 53 ++++++++++++++++++++++++++++++ Project/php/model/Student.php | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 Project/php/model/MdlStudent.php create mode 100644 Project/php/model/Student.php diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php new file mode 100644 index 0000000..a59b21a --- /dev/null +++ b/Project/php/model/MdlStudent.php @@ -0,0 +1,53 @@ +prepare('SELECT * FROM Student_ WHERE login = :login AND password = :password'); + $query->bindParam(':login', $cleanedLogin, PDO::PARAM_STR); + $query->bindParam(':password', $cleanedPassword, PDO::PARAM_STR); + $query->execute(); + + $student = $query->fetch(PDO::FETCH_ASSOC); + + if ($student) { + // L'authentification a réussi, ajouter le rôle et le login à la session + session_start(); + $_SESSION['role'] = 'student'; // Vous pouvez définir le rôle approprié + $_SESSION['login'] = $cleanedLogin; + return true; + } else { + // L'authentification a échoué + return false; + } + } + + public function deconnexion(){ + session_unset(); + session_destroy(); + $_SESSION = array(); + + } +/* + public function isStudent(){ + if( isset ($_SESSION['login']) && isset ($_SESSION['role'])){ + //Créer une classe nettoyer + $login=Nettoyer::nettoyer_string($_SESSION['login']); + $role=Nettoyer::nettoyer_string($_SESSION['role']); + return new Student($login,$role); + } + else return null; + } +*/ +} \ No newline at end of file diff --git a/Project/php/model/Student.php b/Project/php/model/Student.php new file mode 100644 index 0000000..7926066 --- /dev/null +++ b/Project/php/model/Student.php @@ -0,0 +1,55 @@ +nickname = $nickname; + $this->extraTime = $extraTime; + } + + /** + * @return bool + */ + public function isExtraTime(): bool + { + return $this->extraTime; + } + + /** + * @param bool $extraTime + */ + public function setExtraTime(bool $extraTime): void + { + $this->extraTime = $extraTime; + } + + /** + * @param String $nickname + */ + public function setNickname(string $nickname): void + { + $this->nickname = $nickname; + } + + public function getNickname(): string + { + return $this->nickname; + } + + + + +} \ No newline at end of file