add and search record done
This commit is contained in:
17
function.php
17
function.php
@@ -1,19 +1,22 @@
|
||||
<?php
|
||||
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());
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user