register+login with secur ok

This commit is contained in:
adri
2019-01-02 19:50:36 +01:00
parent 227827b913
commit 100b22a0c1
9 changed files with 66 additions and 97 deletions

View File

@@ -4,21 +4,18 @@ if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$template = $twig->load('login.html.twig');
echo $template->render(array());
if(isset($_POST["login"], $_POST["pw"]))
{
try {
$config = include(SITE_ROOT.'config.php');
$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 = ? AND mot_de_passe = ?');
$req->exexute(array(htmlspecialchars($_POST["login"]),md5($_POST["pw"])));
$req->execute(array(htmlspecialchars($_POST["login"]),md5($_POST["pw"])));
if($req->rowCount() > 0)
{
$data = $req->fetch();
@@ -29,5 +26,11 @@ if(isset($_POST["login"], $_POST["pw"]))
else
echo json_encode((object)array("login"=>false));
}
elseif(isset($twig)) {
$template = $twig->load('login.html.twig');
echo $template->render(array());
}
?>

View File

@@ -15,6 +15,6 @@ for($i=0;$data = $reponse->fetch();$i++) {
$datas[$i] = $data;
}
$reponse->closeCursor();
echo $template->render(array('datas' => $datas));
echo $template->render(array('datas' => $datas, "session" => $_SESSION));
?>