-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentification.php
30 lines (26 loc) · 1.23 KB
/
identification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// Permet de se connecter
session_start();
require_once 'config.php';
//Si toutes ces entrées sont renseignées
if(isset($_POST['identifiant']) && $_POST['password'])
{
$identifiant = htmlspecialchars($_POST['identifiant']);
$password = htmlspecialchars($_POST['password']);
// Vérifie si la personen existe
$check = $bdd->prepare('SELECT identifiant, password FROM utilisateurs WHERE identifiant = ?');
$check->execute(array($identifiant));
$data = $check->fetch();
$row = $check->rowCount();
// Vérifie si la personne existe et que le mot de passe correspond
if($row > 0)
{
// Si le mot de passe est bon
if(password_verify($password, $data['password']))
{
//Création de session et redirection vers map.php pour accéder à la carte
$_SESSION['user'] = $data['identifiant'];
header('Location:map.php');
}else{ header('Location: connexion.php?login_err=password'); die(); }
}else{ header('Location: connexion.php?login_err=identifiant'); die(); }
}else{ header('Location: connexion.php'); die();}