|
|
@ -6,18 +6,31 @@ require("connectionBD.php");
|
|
|
|
$db = connexionBD();
|
|
|
|
$db = connexionBD();
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function printError(){
|
|
|
|
|
|
|
|
if(isset($_GET['error'])){
|
|
|
|
|
|
|
|
$erreur = getError($_GET['error']);
|
|
|
|
|
|
|
|
echo "<p class = 'error'>$erreur</p>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getError($code){
|
|
|
|
|
|
|
|
switch ($code){
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
return "Adresse mail ou mot de passe invalide.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function authentification($db, $mail, $password){
|
|
|
|
function authentification($db, $mail, $password){
|
|
|
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
|
|
|
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
|
|
|
|
if ($result){
|
|
|
|
if ($result){
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
|
$row = pg_fetch_array($result);
|
|
|
|
return (!strcmp($row["passwd"], $password));
|
|
|
|
return (strcmp($row["passwd"], $password)) == 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function init(){
|
|
|
|
function init(){
|
|
|
|
|
|
|
|
global $db;
|
|
|
|
session_start();
|
|
|
|
session_start();
|
|
|
|
|
|
|
|
|
|
|
|
if(!isset($_SESSION['mail'])){
|
|
|
|
if(!isset($_SESSION['mail'])){
|
|
|
@ -31,7 +44,7 @@ function init(){
|
|
|
|
header('Location: tableauBord/tableauBord.php');
|
|
|
|
header('Location: tableauBord/tableauBord.php');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
header('Location: index.php?error=Adresse mail ou mot de passe invalide.');
|
|
|
|
header('Location: index.php?error=1');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -62,7 +75,7 @@ function init(){
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
if(isset($_GET['error'])){
|
|
|
|
if(isset($_GET['error'])){
|
|
|
|
$erreur = $_GET['error'];
|
|
|
|
$erreur = getError($_GET['error']);
|
|
|
|
echo "<p class = 'error'>$erreur</p>";
|
|
|
|
echo "<p class = 'error'>$erreur</p>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|