Si... sulla stessa cartella
eccoti il utenti.php:
Codice PHP:
<?
$utenti["aaa"] = "bbb";
$utenti["admin1"] = "pass1";
?>
area_riservata.php
Codice PHP:
<?
session_start();
if(!isset($_SESSION["utente"])){
include("login.php");
die();
}
?>
e poi login.php
Codice PHP:
<? session_start(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</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" method="post">
<input type="text" name="utente" size="20" /></td>
<input type="password" name="password" size="20" /></td>
<input name="submit" type="submit" class="Stile2" value=" OK " /> </td>
</form>
<? }
if(isset($_POST["utente"]))
{
if (check($_POST["utente"],$_POST["password"]))
{
$_SESSION["utente"] = $_POST["utente"];
$_SESSION["password"] = $_POST["password"];
echo'<meta HTTP-EQUIV="refresh" content=1;url="index.php">';
exit;
}
else
{
form_login();
}
}
else
{
form_login();
}
?>
Grazie!!