projetphp/function.php

24 lines
618 B
PHP
Raw Normal View History

2019-01-02 11:48:16 +01:00
<?php
2019-01-02 13:23:07 +01:00
2019-01-02 11:48:16 +01:00
//SELECT * FROM `projetphp` WHERE `login` = 'aaazzze'
function userExist($login){
2019-01-02 13:23:07 +01:00
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());
}
2019-01-02 11:48:16 +01:00
$req = $bdd->prepare('SELECT * FROM `projetphp` WHERE `login` = :login');
2019-01-02 13:23:07 +01:00
$req->execute(array('login' => htmlspecialchars($login)));
2019-01-02 11:48:16 +01:00
if($req->rowCount() != 0)
{
2019-01-02 13:23:07 +01:00
$req->closeCursor();
2019-01-02 11:48:16 +01:00
return true;
}
else {
2019-01-02 13:23:07 +01:00
$req->closeCursor();
2019-01-02 11:48:16 +01:00
return false;
}
}
?>