Creare una tabella amici, contenente almeno i campi:
ID primary Key, Auto Increment,
cognome varchar(20),
nome varchar (20),
username varchar (20),
password varchar(60)
<!DOCTYPE> <html> <head> <style> #centro { border: 5px groove olive; border-radius: 25px; text-align:center; position:absolute; top:50%; left:50%; margin-top:-140px; margin-left:-200px; width:400px; height:280px; background:#6A5A3A; } input { border:ridge black 3px; border-radius:7px; } </style> </head> <body> <div id="centro"> <?php mysql_connect("localhost", "-------------", "") or die(mysql_error()); mysql_select_db("------------") or die(mysql_error()); errore=0; if (isset($_POST['invio'])) { if (!$_POST['utente'] | !$_POST['pw1'] | !$_POST['pw2'] ) { echo 'non hai inserito tutti i campi<br />'; $errore=1; } if (!get_magic_quotes_gpc()) { $_POST['utente'] = addslashes($_POST['utente']); } $nomeUt = $_POST['utente']; $qryVerifica = mysql_query("SELECT username FROM amici WHERE username = '$nomeUt'") or die(mysql_error()); $conta = mysql_num_rows($qryVerifica); if ($conta != 0) { echo 'Spiacente il nome scelto '.$_POST['utente'].' è già assegnato<br />'; $errore=1; } if ($_POST['pw1'] != $_POST['pw2']) { echo 'le due password sono diverse<br />'; $errore=1; } $_POST['pw1'] = md5($_POST['pw1']); if (!get_magic_quotes_gpc()) { $_POST['pw1'] = addslashes($_POST['pw1']); $_POST['utente'] = addslashes($_POST['utente']); } if ($errore==0) { $qryins = "INSERT INTO amici (cognome, nome, username, password) VALUES ('".$_POST['cog']."', '".$_POST['nom']."', '".$_POST['utente']."', '".$_POST['pw1']."')"; $esito = mysql_query($qryins); if ($esito) { echo "<h1>Registrato</h1> <p>adesso, "; echo "<a href='autentica.php'>autenticandoti</a>"; echo ", puoi accedere all’area riservata</p>"; } else { echo mysql_error(); $errore=1; } } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr> <td>Cognome </td> <td> <input type="text" name="cog"> </td> </tr> <tr> <td>Nome </td> <td> <input type="text" name="nom"> </td> </tr> <tr> <td>nome Utente:</td> <td> <input type="text" name="utente" maxlength="60"> </td> </tr> <tr> <td>Password:</td> <td> <input type="password" name="pw1" maxlength="10"> </td> </tr> <tr> <td>Conferma la Password:</td> <td> <input type="password" name="pw2" maxlength="10"> </td> </tr> <tr> <th colspan=2><input type="submit" name="invio" value="Registrami"> </th> </tr> </table> </form> </div> </body> </html>
Modificare lo script e la tabella del database, in modo da inviare una mail contenente un codice di attivazione. L'account viene convalidato se l'utente risponde inviando il codice di attivazione corretto.