Voici un script d'identification basique avec les sessions, évidemment il n'est pas à utiliser tel quel.

page login.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>login</title>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="gaspard from freelancis" />
	<meta http-equiv="imagetoolbar" content="no" />
 
</head>
 
<body>
 
<form action="connect.php" method="post" accept-charset="utf-8">
	<label for="login">login</label><input type="text" name="login" value="" id="login">
	<label for="password">password</label><input type="password" name="password" value="" id="password">
 
 
 
	<p><input type="submit" value="Continue &rarr;"></p>
</form>
 
</body>
</html>

page connect.php

<?php
	session_start();
 
	if(($_REQUEST['login']=='gaspard') && ($_REQUEST['password']=='choucroute')){
		$_SESSION['login']=$_REQUEST['login'];
		$_SESSION['level']=1;
 
		echo 'information secrete <a href="secret.php">autre secret</a>';
 
 
	}
	else{
		echo 'mot de passe incorrect <a href="login.html">vtff</a>';
 
	}
 
?>

page secret.php

<?php
	session_start();
	if(isset($_SESSION['level'])){
		if($_SESSION['level']>0){
			echo 'ceci est un secret';
		}
 
	}
?>
ressources/php/amphi07.txt · Last modified: 2013/06/16 22:51 (external edit)
 
 
Creative Commons License Powered by PHP Valid XHTML 1.0 April