Problema registrazione e login
Ho creato un sistema di registrazione e login per utenti, però non capisco il perchè ma non mi inserisce i dati nel database..ecco il codice di registrazione
Codice PHP:
<?php
// connessione al database
mysql_connect("localhost", "******", "*****") or die(mysql_error());
mysql_select_db("********") or die(mysql_error());
if (isset($_POST['submit'])) {
// controlla che non ci siano campi vuoti
if (!$_POST['nome'] | !$_POST['cognome'] | !$_POST['mail'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('Non hai completato tutti i campi!');
}
// Controlla che la mai non sia in uso
if (!get_magic_quotes_gpc()) {
$_POST['mail'] = addslashes($_POST['mail']);
}
$mailcheck = $_POST['mail'];
$check = mysql_query("SELECT mail FROM utenti WHERE mail = '$mailcheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
// Se la mail esiste già da errore
if ($check2 != 0) {
die('Errore: la mail '.$_POST['mail'].' è già in uso.');
}
// Controlla che le due password combacino
if ($_POST['pass'] != $_POST['pass2']) {
die('Le due password non combaciano. ');
}
// Cripta la password
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['nome'] = addslashes($_POST['nome']);
$_POST['cognome'] = addslashes($_POST['cognome']);
$_POST['mail'] = addslashes($_POST['mail']);
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['pass2'] = addslashes($_POST['pass2']);
}
// Ora lo inserisce nel database
$insert = "INSERT INTO utenti (nome, cognome, mail, pass, pass2)
VALUES ('".$_POST['nome']."', '".$_POST['cognome']."', '".$_POST['mail']."', '".$_POST['pass']."', '".$_POST['pass2']."')";
$add_member = mysql_query($insert);
?>
<h1>Registrato!</h1>
<p>Grazie per esserti registrato!.</p>
<?php
}
else
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Nome:</td><td>
<input type="text" name="nome" maxlength="30">
</td></tr>
<tr><td>Cognome:</td><td>
<input type="text" name="cognome" maxlength="30">
</td></tr>
<tr><td>Mail:</td><td>
<input type="text" name="mail" maxlength="30">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="30">
</td></tr>
<tr><td>Conferma Password:</td><td>
<input type="password" name="pass2" maxlength="30">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit"
value="Registrati"></th></tr> </table>
</form>
<?php
}
?>
vi sarei grato se qualcuno mi correggesse nelle cose che sbaglio per capire! grazie mille!