diff --git a/function.php b/function.php index 97e1ad7..59367dd 100644 --- a/function.php +++ b/function.php @@ -1,19 +1,22 @@ getMessage()); -} + //SELECT * FROM `projetphp` WHERE `login` = 'aaazzze' function userExist($login){ + try { + $config = include('config.php'); + $bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']); + } catch (Exception $e) { + die('Erreur : '.$e->getMessage()); + } $req = $bdd->prepare('SELECT * FROM `projetphp` WHERE `login` = :login'); - $req->execute(array('login' => htmlspecialchars($_POST["userToDel"]))); + $req->execute(array('login' => htmlspecialchars($login))); if($req->rowCount() != 0) { + $req->closeCursor(); return true; } else { + $req->closeCursor(); return false; } } diff --git a/index.php b/index.php index da30177..f0dd0de 100755 --- a/index.php +++ b/index.php @@ -25,7 +25,7 @@ $reponse = $bdd->query('SELECT * FROM projetphp'); - +
@@ -69,5 +70,28 @@ while ($data = $reponse->fetch()) { |