Gli errori sono abilitati sul server
Questo è lo script original su cui si basa lo schema del log-in
<? session_start(); @include "../config/config.php"; //controliamo l'invio dei dati if ((isset($_GET["op"])) && ($_GET["op"]== "login")){ if (!$_POST["username"] || !$_POST["password"]) { die("<p align= \"center\">Devi inserire sia username che password.</p> <p align= \"center\"><a href=\"index.php\">Riprova a loggarti</a></p>"); } $username = $_POST["username"]; $password = sha1($_POST["password"]); //query d'estrazione dei dati di login $query = "SELECT * FROM $tabella_admin WHERE adm_username = '$username' AND adm_password = '$password'"; $result = @mysql_query($query) or die (mysql_error()); if ($obj = @mysql_fetch_object($result)) { //crea la sessione $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_pass"] = $_POST["password"]; $_SESSION["valid_time"] = time(); //sessione creata. vai alla pagina di gestione delle news header("Location: adm_news.php"); } else { // Messaggio di errore die("<p align= \"center\">Impossibile accedere all'area riservata. Username o password errati.</p> <p align= \"center\"><a href=\"index.php\">Riprova a loggarti</a></p>"); } } else { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Login Admin</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../css/website.css"> </head> <body> <table width="500" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td bgcolor="#FFCC33"> <table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="70%"> <? echo "<form action=\"?op=login\""; ?> method="post" name="login_form""> <table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#000000"> <tr bgcolor="#cccccc"> <td width="15%" align="center"><h1>Login Admin</h1></td> </tr> <tr> <td align="center"> <table width="250" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100"><h2>username:</h2></td> <td width="150"><input type="text" name="username"></td> </tr> </table></td> </tr> <tr> <td align="center"><table width="250" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100"><h2>password:</h2></td> <td width="150"><input type="password" name="password"></td> </tr> </table></td> </tr> <tr> <td align="center"><table width="160" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right"><input type="submit" name="submit" value="login"></td> </tr> </table></td> </tr> </table> </form></td> </tr> </table></td> </tr> </table> </body> </html> <? } ?>è funziona senza problemi ma a me non piace perchè preferisco avere 2 file distinti uno con il for e l'altro con solo php che esegue i controlli sui dati inviati