Ciao a tutti!Vorrei rendere più sicura la registrazione al mio sito CRIPTANDO le password degli iscritti con MD5 e inserendo un modulo CAPTCHA.
A inoltre vorrei anche poter inserire la data di registrazione.
Ecco il codice che ho scritto finora:
Grazie e buona giornata!
A inoltre vorrei anche poter inserire la data di registrazione.
Ecco il codice che ho scritto finora:
PHP:
<?php
include('connect.php');
function filtro_db($stringa)
{
$stringa = trim ($stringa);
if(empty($stringa))
{
return FALSE;
}
else if(get_magic_quotes_gpc())
{
stripslashes($stringa);
}
return mysql_real_escape_string($stringa);
}
$user = filtro_db($_POST['user']);
$pass = filtro_db($_POST['pass']);
$mail = filtro_db($_POST['mail']);
$manager = filtro_db($_POST['manager']);
$team = filtro_db($_POST['team']);
//controllo se i campi sono vuoti
if(!$user || !$pass || !$mail || !$manager || !$team)
{
header("location:error1.php");
exit;
}
//controllo che la mail sia scritta in modo corretto
if (!ereg("^[a-z0-9][_.a-z0-9-]+@([a-z0-9][0-9a-z-]+.)+([a-z]{2,4})",$mail))
{
header("location:error3.php");
exit;
}
if(!preg_match('/^[A-Za-z0-9]{6,25}$/',$user))
if(!preg_match('/^[A-Za-z0-9]{6,25}$/',$pass))
if(!preg_match('/^[A-Za-z0-9]{6,25}$/',$manager))
if(!preg_match('/^[A-Za-z0-9]{6,25}$/',$team))
{
header("location:error4.php");
exit;
}
//verifico se ci sono utenti con lo stesso user o email
$query_1=mysql_query("SELECT * FROM iscritti WHERE email='".$mail."' or nickname='".$user."'")
or die("errore nella query;".mysql_error());
$num=mysql_num_rows($query_1);
//se ci sono campi gia occupati
if($num > 0)
{
header("location:error2.php");
exit;
}
//altrimenti procedo con l'inserimento
else
{
$query_insert=mysql_query("INSERT INTO iscritti
(nickname, password, email, manager, team)
VALUES
('$user', '$pass', '$mail', '$manager',
'$team')")or die("errore nella query;".mysql_error());
$query_insert=mysql_query("INSERT INTO squadra_dati
(manager, team, punti, livello, cash, vittorie, pareggi, sconfitte)
VALUES
('$manager', '$team', '0', 'Amateur League', '10000000 Coins' '0' '0' '0')")or die("errore nella query;".mysql_error());
header("location:reg_success.php");
function mostra_form()
{
if(isset($_GET['msg']))
echo '<b>'.htmlentities($_GET['msg']).'</b><br /><br />';
}
}
?>
Grazie e buona giornata!