Codice PHP:
</head>
<body <?php
$error_message = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['form_name']) && $_POST['form_name'] == 'loginform')
{
$success_page = './Login_eseguito.php';
$error_page = './Login_Errato.php';
$database = './usersdb.php';
$crypt_pass = md5($_POST['password']);
$found = false;
$fullname = '';
$session_timeout = 600;
if(filesize($database) > 0)
{
$items = file($database, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($items as $line)
{
list($username, $password, $email, $name, $active) = explode('|', trim($line));
if ($username == $_POST['username'] && $active != "0" && $password == $crypt_pass)
{
$found = true;
$fullname = $name;
}
}
}
if($found == false)
{
$error_message = 'I dati inseriti non sono corretti';
}
else
{
if (session_id() == "")
{
session_start();
}
$_SESSION['username'] = $_POST['username'];
$_SESSION['fullname'] = $fullname;
$_SESSION['expires_by'] = time() + $session_timeout;
$_SESSION['expires_timeout'] = $session_timeout;
$rememberme = isset($_POST['rememberme']) ? true : false;
if ($rememberme)
{
setcookie('username', $_POST['username'], time() + 3600*24*30);
setcookie('password', $_POST['password'], time() + 3600*24*30);
}
header('Location: '.$success_page);
exit;
}
}
$username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
$password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
?>
<div id="wb_Shape1" style="position:absolute;left:241px;top:328px;width:1031px;height:2329px;z-index:2;">
<div id="Shape1"></div></div>
<div id="wb_Form1" style="position:absolute;left:942px;top:1913px;width:328px;height:225px;z-index:3;">
<form name="Form1" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)">
<input type="hidden" name="formid" value="form1">
<textarea name="TextArea1" id="TextArea1" style="position:absolute;left:10px;top:32px;width:287px;height:132px;z-index:0;" rows="8" cols="46" placeholder="Dacci un suggerimento su un trucco che vorresti vedere su queste pagine"></textarea>
<input type="submit" id="Button1" name="" value="Invia" style="position:absolute;left:214px;top:186px;width:96px;height:25px;z-index:1;">
</form>
</div>
<div id="wb_Text1" style="position:absolute;left:290px;top:449px;width:250px;height:28px;z-index:4;text-align:left;">
<span style="color:#696969;font-family:'Malgun Gothic';font-size:20px;">Ultime Novità</span></div>
<div id="wb_Text2" style="position:absolute;left:620px;top:890px;width:250px;height:28px;z-index:5;text-align:left;">
<span style="color:#696969;font-family:'Malgun Gothic';font-size:20px;">Notizie del Mese</span></div>
<div id="wb_Text3" style="position:absolute;left:289px;top:890px;width:250px;height:28px;z-index:6;text-align:left;">
<span style="color:#696969;font-family:'Malgun Gothic';font-size:20px;">SuperNews del mese</span></div>
<div id="wb_Info" style="position:absolute;left:917px;top:2032px;width:21px;height:18px;z-index:7;">
<a id="Info" style="visibility:hidden"> </a>
</div>
...
...
<div id="Html2" style="position:absolute;left:816px;top:33px;width:516px;height:388px;z-index:97">
<html >
<head>
<meta charset="UTF-8">
<title>Login Form</title>
</head>
<body>
<div class="login">
<div class="login-triangle"></div>
<form class="login-container" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform">
<input type="hidden" name="form_name" value="loginform">
<h2 class="login-header">Log in</h2>
<p><input class="input" name="username" type="text" id="username" value="<?php echo $username; ?>" placeholder="Username"/></p>
<p><input class="input" name="password" type="password" id="password" value="<?php echo $password; ?>" placeholder="Password"></p>
<p class="errore"> <?php echo $error_message; ?> </p>
<p><input type="submit" value="Log in"></p>
</form>
</div>
</body>
</html>
</div>
</body>
</html>