if(isset($_POST['registra']))
{
$cognome_utente = (isset($_POST['cognome_utente'])) ? trim($_POST['cognome_utente']) : '';
$nome_utente = (isset($_POST['nome_utente'])) ? trim($_POST['nome_utente']) : '';
$pass = (isset($_POST['pass'])) ? trim($_POST['pass']) : '';
$mail = (isset($_POST['mail'])) ? trim($_POST['mail']) : '';
if (!get_magic_quotes_gpc()) {
$cognome_utente = addslashes($cognome_utente);
$nome_utente = addslashes($nome_utente);
$pass = addslashes($pass);
$mail = addslashes($mail);
}
if(strlen($cognome_utente) < 4 || strlen($cognome_utente) > 12)
die('Cognome troppo corto, o troppo lungo');
if(strlen($nome_utente) < 4 || strlen($nome_utente) > 12)
die('Nome troppo corto, o troppo lungo');
elseif(strlen($pass) < 4 || strlen($pass) > 12)
die('Password troppo corta, o troppo lunga');
elseif(!eregi("^[a-z0-9][_\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\.)+([a-z]{2,4})", $mail))
die('Email non valida');
elseif(mysql_num_rows(mysql_query("SELECT cognome_utente FROM utenti WHERE cognome_utente = '$cognome_utente' LIMIT 1")) == 1)
die('Cognome Utente non disponibile');
elseif(mysql_num_rows(mysql_query("SELECT mail FROM utenti WHERE mail = '$mail' LIMIT 1")) == 1)
die('Questo indirizzo email risulta già registrato ad un altro utente');
else
{
$pass = md5($pass);
$strSQL = "INSERT INTO utenti (cognome_utente, nome_utente, pass, mail)";
$strSQL .= "VALUES('$cognome_utente', '$nome_utente', '$pass', '$mail')";
mysql_query($strSQL) OR die("Errore 003, contattare l'amministratore ".mysql_error());
utente ad una pagina di conferma della registrazione
header('Location: registrato.php');
exit;
}
}
$query=mysql_query("SELECT id FROM utenti LIMIT 10");
$utenti=mysql_num_rows($query);
if($utenti < 10){
}else{
echo "<center><b><h3>SUPERATO IL LIMITE UTENTI REGISTRATI</h3></b></center><br><br>";
}
?>
<title>Registrazione</title>
</head>
<body>
<div align="center">
<form action="" method="post">
<table bgcolor="#bdd3ad" cellspacing="1" cellpadding="10" border="1">
<tr>
<th colspan=2>REGISTRATI ALL'AREA PRIVATA</th>
</tr>
<tr>
<td width="90" align="right"><font face="Verdana" size="2">COGNOME</font>:</td>
<td width="140"><input name="cognome_utente" type="text" id="cognome_utente" value="" size="15" align="middle onfocus="if(this.value=='Nome Utente') this.value='';" /><br /></td>
</tr>
<tr>
<td width="90" align="right"><font face="Verdana" size="2">NOME</font></td>
<td width="140"><input name="nome_utente" type="text" id="nome_utente" value="" size="15" align="middle onfocus="if(this.value=='Nome Utente') this.value='';" /><br /></td>
</tr>
<tr>
<td width="90" align="right"><font face="Verdana" size="2">PASSWORD</font></td>
<td width="140"><input name="pass" type="password" id="pass" value="" size="15" align="middle onfocus="if(this.value=='Password') this.value='';" /><br /><br /></td>
</tr>
<tr>
<td width="90" align="right"><font face="Verdana" size="2">E-MAIL</font></td>
<td width="140"><input name="mail" type="text" id="mail" value="" size="15" align="middle onfocus="if() this.value='';" /><br /><br /></td>
</tr>
<tr>
<td colspan="2" height="60" align="center">
<input name="registra" width=80 type="submit" value="REGISTRATI" align=middle onclick="check()">
<input name="reset" type="reset" value="ANNULLA" width=80 align=middle>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>