public function validateLogin() {
if ($this->isPost) {
$this->email = getRequestVar("email");
if (empty($this->email)) {
$this->emailError = "Email is required";
}
$this->password = getRequestVar("password");
if (empty($_POST["password"])) {
$this->passwordError = "Password is required";
}
// TODO: Add 'if' all errors are empty here before authenticating
$this->authenticateUser();
}
}
▶️ idem in validateForm, validateChangePassword en validateRegister
Onderstaande functie https://github.com/AchrafReyani/educom-webshop-oop/blob/94f640cb74d03d8a00558191f593a082ba3aae81/models/PageModel.php#L26-L33
Haalt niet alleen de data uit de
$_GET
maar ook uit de$_POST
, een naam alsgetRequestVar
zou beter op zijn plek zijn.Daarnaast zou ik de $this->isPost variabele gebruiken dus dan wordt het:
en in plaats van alleen
trim()
zou ik een$this->testInput()
functie gebruiken, zoals onderaan de W3Schools pagina over form validatie wordt gebruikt.Je kan deze functie dan gelijk gebruiken op deze plekken https://github.com/AchrafReyani/educom-webshop-oop/blob/94f640cb74d03d8a00558191f593a082ba3aae81/models/ShopModel.php#L16 wordt dan
https://github.com/AchrafReyani/educom-webshop-oop/blob/94f640cb74d03d8a00558191f593a082ba3aae81/models/ShopModel.php#L39-L44 wordt dan
en overal in de UserModel waar je nu $_POST gebruikt
https://github.com/AchrafReyani/educom-webshop-oop/blob/94f640cb74d03d8a00558191f593a082ba3aae81/models/UserModel.php#L45-L60 wordt dan
▶️ idem in
validateForm
,validateChangePassword
envalidateRegister