<?php
session_start ();//facciamo partire la sessione
//controlliamo i dati inviati
if ((!isset($_POST['utente'])) && (!isset($_POST['password'])))
{
// ecco il form
echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">
User: <input type=\"text\" name=\"username\"><br>
Password: <input type=\"password\" name=\"password\"><br>
<input type=\"submit\" value=\"Invia\"></form>";
}else{
// query in tabella
$sql = mysql_query("SELECT * FROM tabella WHERE username='".$POST['username']."' AND '".$_POST['pasword']."'");
if (mysql_num_rows($sql)>0)
{
$_SESSION['username']=$_POST['username'];
$_SESSION['password']=$_POST['password'];
header("Location: pagina_riservata.php");
}
else {echo "Login errato";}
}
?>