Codice PHP:
$query = "SELECT * FROM config";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_array($result))
{
session_start();
if ($row[user] != $_SESSION['user'] && sha1($row[password]) != $_SESSION['password']) {
$user = $_POST['user'];
$password = sha1($_POST['password']);
$query = "SELECT * FROM config";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_array($result))
{
$_SESSION['user'] = $_POST['user'];
$_SESSION['password'] = $_POST['password'];
if ($user == $row[user] && $password == sha1($row[password])) {
//intestazione
top();
?>
<table width="50%" align="center">
<tr><td width="100%" class="alto"><b>Form Login</b></td></tr>
<tr><td width="100%" height="100" class="vario" align="center">Login effettuato con successo!<br /><a href="amministrazione.php">Vai al Pannello d' Amministrazione!</a></td></tr></table>
<?php
} else {
//intestazione
top();
?>
<table width="50%" border="1" align="center">
<tr><td width="100%" colspan="2" class="alto"><b>Form Login</b></td></tr>
<form action="login.php" method="post">
<tr><td width="50%" class="vario"><b>User:</b></td>
<td width="50%" class="vario"><input type="text" name="user" onfocus="this.style.border='1px #666666 solid;'" onblur="this.style.border='1px #999999 solid;'"></td></tr>
<tr><td width="50%" class="vario"><b>Password:</b></td>
<td width="50%" class="vario"><input type="password" name="password" onfocus="this.style.border='1px #666666 solid;'" onblur="this.style.border='1px #999999 solid;'"></td></tr>
<tr><td width="100%" align="right" colspan="2" class="alto"><input type="submit" name="submit" value="invia">
</table>
</form>
<br />
<?
}
}
} else {
header("location:amministrazione.php");
}
}
Ok, é un po un casino, ma funziona, solo che a fondo pag mi fa vedere sta roba...