Chiedo aiuto premetto che sono un dilettante, mi sto costruendo un sito e tutto sommato ci sono quasi riuscito potete vederlo qui il problema nasce da voler costruire pagine protette con password e username che scelgo io. Mi sto cementanto da diversi giorni con script vari ma non sono riuscito a fare funzionare niente o non funzionano.Lo script e questo composto da 4 file alla luce di tutto cio mi servirebbe un aiuto passo passo alla compilazione di questo script oppure se conoscete uno semplice con guida semplice sarei grato del vostro aiuto
contatto msn:catodon@libero.it
pagina login.php
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
</head>
<body>
<?
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:
<input type="text" name="utente" size="20" maxlength="255">
Password:
<input type="password" name="password" size="20" maxlength="255">
<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>
pagina utenti.php
<?
/*
Per aggiungere un nuovo utente scrivere:
$utenti["nome_utente"] = "password";
Ad esempio, se si vuole aggiungere l'utente mario con password rossi, scrivere:
$utenti["mario"] = "rossi";
*/
$utenti["admin"] = "admin";
?>
area riervata.php
<?
session_start();
if(!isset($_SESSION["utente"])){
include("error.htm");
die();
}
?>
pagina error.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>error</title>
</head>
<body>
Non 6 loggato!
</body>
</html>