ciao a tutti sto facendo il mio sistema di registrazione utenti e mi sono bloccato nel ultimo passaggio, ho gia tutto pronto, ma quando mando il link di conferma x attivare l'account questo non funziona
index HTML
codice HTML:
<!DOCTYPE html>
<html>
<head>
<title>scomania</title>
<meta charset="utf-8">
<meta name="viewport" content="width:device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="server.php">
<table>
<tr>
<td>inserisci il tuo nome completo</td>
<td><input type="text" name="nome" maxlength="20"></td>
</tr>
<tr>
<td>inserisci la tua email</td>
<td><input type="text" name="email" maxlength="20"></td>
</tr>
<tr>
<td>inserisci il tuo numero</td>
<td><input type="text" name="telefono" maxlength="12"></td>
<tr>
<td>inserisci una password</td>
<td><input type="text" name="pw" maxlength="15"></td>
</tr>
<tr>
<td><input type="submit" value="confermare"></td>
</tr>
</table>
</form>
</body>
</html>
server php
codice HTML:
<?php
/* PARAMETRI DI CONESSIONE AL MIO DB MYSQL */
$conex = mysql_connect("localhost", "root", "", "my_db");
mysql_select_db("my_db", $conex);
/* PARAMETRI RECUPERATI DAL FORM */
$nome = $_POST['nome'];
$email = $_POST['email'];
$pw = $_POST['pw'];
$tel = $_POST['tel'];
$data = date('Y-m-d H:i:s');
/* controllo se il token gia esiste nel database, se e positivo rigenero il token */
$token = rand(1, 10);
echo "codice random:".$token."<br>";
$controlloToken = "SELECT token FROM user WHERE token=$token";
$querycontrol = mysql_query($controlloToken);
echo "rispota dal db:".$querycontrol."<br>";
if($querycontrol == true) {$token;}
/* PARAMETRI EMAIL*/
$destinatario = $email;
$ogetto = "CONFERMA LA TUA REGISTRAZIONE";
$mesaggio = "clicka sul link per confermare la tua registrazione wwww.telelavoro.altervista.org/conferma.php";
/* inserisco nel database i dati dell'utente */
$sql = "INSERT INTO user (id, email, password, token, active, data_registed, phone)
VALUES (NULL, '$email', '$pw', '$token', '0', '$data', '$tel')" ;
mysql_query($sql) or die (mysql_error());
mail($destinatario, $ogetto, $mesaggio);
OUTPUT
codice random:7
rispota dal db:Resource id #6
clicki sul link che gli abbiamo mandato per email per completare la registrazione
conferma.php
codice HTML:
<?php
$token = $_GET['token'];
$sql = "SELECT token FROM user WHERE token=$token";
$verifica = mysql_query($ql);
if($verifica == true) {
$query = "UPDATE user set active='1' WHERE token='$token'";
mysql_query($query) or die (mysql_error());
echo "Account attivato";
}
?>
Non mi stampa il mesaggio, ne si attiva l'account