projetphp/function.php

24 lines
618 B
PHP

<?php
//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($login)));
if($req->rowCount() != 0)
{
$req->closeCursor();
return true;
}
else {
$req->closeCursor();
return false;
}
}
?>