anch'io ho questo problema! creare una pagina di login per un solo utente, l'amministratore. ho trovato questo codice su html.it :
è corretto? ma cosa si intende all'inizio per usr='".filtra_caratteri_dannosi($_POST['user']) e poi per pwd='".md5($_POST['pwd'])?codice:<?php require('db_conn/mysql.php'); if (isset($_POST['user'])) { $query_login="SELECT * FROM tabella_utenti WHERE usr='".filtra_caratteri_dannosi($_POST['user'])."' AND pwd='".md5($_POST['pwd'])."'"; $rslt_login=$mysqlwrapper->Execute($query_login) or die("Errore di autenticazione. "); if (!$rslt_login->EOF) { // Esiste un record con questi username più(firma)password: // inserisco i dati nella sessione session_start(); $_SESSION['Username']=$rslt_login->Fields('usr'); $_SESSION['Usergroup']=$rslt_login->Fields('group'); header('location:main.php'); } else header('location:login_failed.php'); } ?> <html> <head> <title>Esempio login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body onLoad="document.form1.user.focus()"> <form name="form1" method="POST" action="index.php"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td>Nome utente: </td> <td><input name="user" type="text" id="user"></td> </tr> <tr> <td>Password: </td> <td><input name="pwd" type="password" id="pwd"></td> </tr> <tr> <td colspan="2"><input name="Submit" type="submit" value="Entra"></td> </tr> </table> </form> </body> </html>

Rispondi quotando