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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| <?php
$host = 'localhost';
$login = 'login';
$password = '';
$bdd = 'xxx';
$pseudo = 'login';
$mdp = 'mdp';
if(!isset($_SESSION['login']) && !isset($_SESSION['password']) || empty($_SESSION['login']) || empty($_SESSION['password'])){
?>
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
<title>Les Gourmets Explorateurs - Admin</title></head>
<body>
<form method=post>
<div align=center>
<b>Nom de compte</b><br>
<input type=text name=login><br>
<b>Mot de passe</b><br>
<input type=password name=password><br>
<input type=submit>
</div>
</form>
</body>
</html>
<?php
}
else{
header('Location: test.php');
}
if(isset($_POST['login']) && isset($_POST['password'])){
$auth_pseudo = $_POST['login'];
$auth_mdp = $_POST['password'];
$erreur = null;
function verification(&$erreur,$auth_pseudo,$auth_mdp){
if(empty($auth_pseudo) || empty($auth_mdp)){
$erreur = 'Un ou plusieurs champs du formulaire sont vide';
return false;
}
if($auth_pseudo != $pseudo || $auth_mdp != $mdp){
$erreur = 'Le pseudo ou mot de passe n\'est pas celui attendu';
return false;
}
}
$check = verification($erreur,$auth_pseudo,$auth_mdp);
if(check){
header('Location: test.php');
}
if($erreur != ''){
echo $erreur;
}
} |