Ho questo script di registrazione che funziona benissimo, solo ora non riesco a capire il meccanismo di invio della conferma email, in altre parole, non invia la mail coi dati, non capisco l'errore, posto lo script che uso:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Documento senza titolo</title>
</head>
<body>
<?php
include ("Config.php");
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['mail'] ) {
die('Completare TUTTI i campi, Grazie.');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM log_user WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die(" ATTENZIONE, L' username ".$_POST['username']." e' gia'* in uso ");
}
// checks if the mail is in use
if (!get_magic_quotes_gpc()) {
$_POST['mail'] = addslashes($_POST['mail']);
}
$mailcheck = $_POST['mail'];
$check = mysql_query("SELECT email FROM log_user WHERE email = '$mailcheck'")
or die(mysql_error());
$mailcheck2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($mailcheck2 != 0) {
die("Attenzione, L' Email ".$_POST['mail']." e' gia' in uso.");
}
// checks if the mail correct.
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$_POST['mail'] )){
die("Attenzione, L' Email ".$_POST['mail']." e' incorretta.");}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Le password non corrispondono. ');
}
// here we encrypt the password and add slashes if needed
$pass = $_POST['pass'];
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}
// now we insert it into the database
$token = "testo a caso";
$mailcr = md5($_POST['email'].$token);
$insert = "INSERT INTO log_user (username, password, email, account)
VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['mail']."', '".$mailcr."')";
$add_member = mysql_query($insert);
?>
<h1>Registrato con Successo!</h1>
Grazie, si e' correttamente registrato, Confermi la registrazione con l' email che le e' stata inviata.</a>.</p>
<?php
}
else
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="60">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>
<tr><td>Conferma Password:</td><td>
<input type="password" name="pass2" maxlength="10">
</td></tr>
<tr><td>Email:</td><td>
<input type="text" name="mail" maxlength="60">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Registrati"></th></tr> </table>
</form>
<?php
}
?>
<?php
// email per la conferma
// intestazioni
$date = time('dmy');
$headers = "From: stefy810@hotmail.it";
$subject = "Conferma la tua iscrizione.";
//corpo del messaggio
$messaggio = "Ti ringraziamo per la tua iscrizione.\n";
$messaggio .= "La tua user è: ".$_POST['username']."\n";
$messaggio .= "La tua password è: ".$pass."\n";
$messaggio .= 'Per confemare vai alla pagina http://www.novitech.ignorelist.com/l...tion.php?user='.$mailcr.'&date='.$date.'';
// invio dell'email
@mail($_POST['mail'], stripslashes($subject),stripslashes($messaggio),$h eaders);
?>
</body>
</html>
credo sia corretto, aver separato l'invio della mail, dal riempimento dei dati, se pur nel medesimo file...mi date un aiuto nell'invio?