From 9eb1041ce7a2dca6015eaf90632f0e9c3f2cdb94 Mon Sep 17 00:00:00 2001 From: "nicolas.franco" Date: Fri, 23 Dec 2022 18:37:16 +0100 Subject: [PATCH] connection error management --- config/config.php | 4 ++-- controller/VisitorCtrl.php | 4 +++- index.php | 2 +- model/UserModel.php | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config/config.php b/config/config.php index 7f5428a..4ab0587 100644 --- a/config/config.php +++ b/config/config.php @@ -3,8 +3,8 @@ $rep=__DIR__.'/../'; - //$con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); - $con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); + $con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); + //$con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); $TMessage = array(); diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index 63a73fe..4937113 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -119,7 +119,9 @@ class VisitorCtrl } function connection(){ - $this->userModel->connexion($_POST['username'],$_POST['password']); + $isCo = $this->userModel->connexion($_POST['username'],$_POST['password']); + if($isCo) + $this->TMessage[] = 'This user does not exist'; require($this->TabVues["erreur"]); $this->loadHome(); } diff --git a/index.php b/index.php index 8a4b373..58fa1bc 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,8 @@ diff --git a/model/UserModel.php b/model/UserModel.php index 0a74197..de8734c 100644 --- a/model/UserModel.php +++ b/model/UserModel.php @@ -19,10 +19,11 @@ Validation::val_form_mdp($mdp, $this->TMessage); $result = $this->gat->findUser($login, $mdp); - if(!isset($result)) echo 'not set works'; - else - { + if(!isset($result)){ + return false; + } else { $_SESSION['login'] = $result; + return true; } }