login.php 1.28 KB
<?php
session_start();
if(isset($_POST['identifiant']) && isset($_POST['mdp'])){
	//Connexion à la base de données
	$db_user = 'lwadbled';
	$db_mdp = 'glopglop';
	$db_nom = 'lwadbled';
	$db_host = 'localhost';
	$db = mysqli_connect($db_host, $db_user, $db_mdp, $db_nom)
		or die('could not connect to database');

	$identifiant = mysqli_real_escape_string($db,htmlspecialchars($_POST['identifiant']));
	$mdp = mysqli_real_escape_string($db,htmlspecialchars($_POST['mdp']));

	if($identifiant !=="" && $mdp !== ""){
		$requete = "SELECT count(*) FROM utilisateur WHERE
			login = '".$identifiant."' AND mdp = '".$mdp."' ";
		$exec_requete = mysqli_query($db,$requete);
		$reponse = mysqli_fetch_array($exec_requete);
		$count = $reponse['count(*)'];
		if($count!=0){
			$_SESSION['identifiant'] = $identifiant;
			echo "<meta http-equiv=\"refresh\" content=\"0;url=menu.php\">";
			//header('Location : menu.php');
		}else{
			echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">";
			//header('Location : index.html');
		}
	}else{
		echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">";
		//header('Location : index.html');
	}
	mysqli_close($db); // Fin de la connexion
}else{
	//header('Location : /index.html');
	echo "<meta http-equiv=\"refresh\" content=\"0;url=index.html\">";
}

?>