Codice login:
Codice PHP:
<?php
error_reporting(E_ALL);
session_start();
include("../config.php");
$script='<link rel="stylesheet" href="../css/login.css" type="text/css" />';
if(!isset($_SESSION['admin'])){
if(!isset($_GET['action'])){
$content='<div id="container">
<div id="content">
<h2>Per cortesia devi loggarti</h2>
Inserisci il tuo nome utente e password per continuare.</p>
<form method="post" action="login.php?action=attendere">
<div class="form_container">
<div class="label"><label for="username">Nome utente:</label></div>
<div class="field"><input type="text" name="username" id="username" class="text_input initial_focus" /></div>
<div class="label"><label for="password">Password:</label></div>
<div class="field"><input type="password" name="password" id="password" class="text_input" /></div>
</div>
<p class="submit">
<input type="submit" value="Login" />
</p>
</form>
</div>
</div>
';
}elseif($_GET['action']=="attendere"){
if($_POST['username']==$username && $_POST['password']==$password){
$_SESSION['admin']=1;
header("Location: home.php");
}else{
header("Location: login.php");
}
}
}else{
header("Location: home.php");
};
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Effettua il login</title>
<?=$script?>
</head>
<body>
<?=$content?>
</body>
</html>
Qui c'è la sessione admi che e vale 0 ti fa fare l'accesso altrimenti ti spedisce allahome del pannello..