<?php
//attivo la sessione
session_start();
?>
<html>
<head>
<title>LogIn</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="template/my_css.css">
</head>
<body>
<table width="60%" border="0" align="center">
<tr>
<td><div align="center">[img]/gestore/immagini/banner.jpg[/img]</div></td>
</tr>
</table>
<?php
//includo il file di configurazione
include("dbconfig.php");
//ricavo i valori della form precedente
$nome = $_POST["nick"];
$password = $_POST["psw"];
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
echo "Errore nella connesione";
if ((mysql_select_db($db_database, $db)) == FALSE)
echo "Errore nella selezione del database" . mysql_error() . "
";
//creo la query
$sql = "SELECT * FROM tbl_utente WHERE nick='$nome' and password='$password'";
//invio tale query al db
$result = mysql_query ($sql, $db);
//ricavo i dati dal db
$row = mysql_fetch_array ($result);
echo mysql_error();
//numero di riche contenente i dati
$num = mysql_num_rows($result);
echo mysql_error();
//$_SESSION["utente"] = $nome;
if ($num != 0)
{ // apertura if utente trovato
$diritto = $row["diritto"];
if ((!empty($diritto)) && ($diritto == 1))
{ //apertura if l'utente è un amministratore
$_SESSION["utente"] = $nome;
header("Location : http://192.168.100.100/gestore/root_page.php");
} //chiusura if l'utente non è un amministratore
else
{ // apertura else l'utente NON è un amministratore
$_SESSION["utente"] = $nome;
header("Location : http://192.168.100.100/gestore/simple_page.php");
} // chiusura else l'utente NON è un amministratore
} //chiusura if utente trovato
else
{ // apertura else utente NON trovato
echo "
<table width='60%' border='0' align='center'>
<tr>
<td><div align='center'><h2 class='title'>Modulo di Direzione</h2></div></td>
</tr>
</table>
<table width='60%' border='1' align='center'>
<tr>
<td colspan='3'><div align='center'>
Il nome non �presente nel database
oppure hai sbagliato la password.
Cosa vuoi vare?
</td>
</table>
<table width='40%' border='0' align='center'>
<tr>
<td><div align='center'><a href='registra.php?n=$nome&p=$password'>Registra
Utente</a></div></td><td><div align='center'><a href='login.php'>Ritorna
al Login</a></div></td>
<td><div align='center'>HomePage</div></td>
</tr>
</table>";
} // chiusura else utente NON trovato
?>
<table width="60%" border="0" align="center">
<tr>
<td><div align="center">[img]/gestore/immagini/downpage.jpg[/img]</div></td>
</tr>
</table>
</body>
</html>
Questo è il codice.. ditemi voi..
![]()
![]()
![]()
![]()
![]()
![]()
![]()