Codice:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
</head>
<body>
ue<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<p>
<?
function check($user,$password){
include("utenti.php");
foreach($utenti as $user_ => $password_){
if (($user==$user_) AND ($password==$password_)) {
return true;
}
}
return false;
}
function form_login(){
?>
<form id="login" action="<?=$PHP_SELF?>" method="post">
<div style="text-align:center;margin-left:auto;margin-right:auto;">
Utente:<br>
<input type="text" name="utente" size="20" maxlength="255"><br>
Password:<br>
<input type="password" name="password" size="20" maxlength="255"><br><br>
<input type="submit" value=" OK ">
</div>
</form>
<? }
if(isset($_POST["utente"])){
if (check($_POST["utente"],$_POST["password"])){
$_SESSION["utente"] = $_POST["utente"];
$_SESSION["password"] = $_POST["password"];
echo "ora sei loggato!";
}else{
form_login();
}
}else{
form_login();
}
?>
</body>
</html>