Salve ragazzi, vi posto questo codice che ho trovato su internet. Sto cercando di implementare sul mio sito, ma c'è qualcosa che non mi quadra:
1) Non riesco a capire da dove selezione il codice che selezione la mail a cui inviare la conferma della registrazione;
2) La mail non viene neanche chiesta tra i dati da inserire nel database
3) Quando provo a fare una registrazione, lui mi inserisce i campi nel database ma non mi manda la mail per confermare e mi da questo errore:
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. n17sm24532865eei.3 in C:\xampp\htdocs\Backupsito\registrazione\include\r eg.php on line 27
Registrazione Fallita a causa di un errore interno.
Sotto il codice. QUALCUNO mi sa dire dove sono gli errori? Io lo guardo e riguardo ma ci sono quei tre punti che non mi tornano.
Grazie
Lollo
<?php
function reg_register($data){
//registro l'utente
global $_CONFIG;
$id = reg_get_unique_id();
mysql_query("
INSERT INTO ".$_CONFIG['table_utenti']."
(name, surname, indirizzo, occupazione, username, password, temp, regdate, uid)
VALUES
('".$data['name']."','".$data['surname']."','".$data['indirizzo']."',
'".$data['occupazione']."','".$data['username']."',MD5('".$data['password']."'),
'1', '".time()."','".$id."')");
//Decommentate la riga seguente per testare lo script in locale
//echo "<a href=\"http://localhost/Articoli/autenticazione/2/scripts/confirm.php?id=".$id."\">Conferma</a>";
if(mysql_insert_id()){
return reg_send_confirmation_mail($data['mail'], "test@localhost", $id);
}else return REG_FAILED;
}
function reg_send_confirmation_mail($to, $from, $id){
//invio la mail di conferma
$msg = "Per confermare l'avvenuta registrazione, clicckate il link seguente:
http://localhost/Articoli/autenticaz...onfirm.php?id=".$id."
";
return (mail($to, "Conferma la registrazione", $msg, "From: ".$from)) ? REG_SUCCESS : REG_FAILED;
}
function reg_clean_expired(){
global $_CONFIG;
$query = mysql_query("
DELETE FROM ".$_CONFIG['table_utenti']."
WHERE (regdate + ".($_CONFIG['regexpire'] * 60 * 60).") <= ".time()." and temp='1'");
}
function reg_get_unique_id(){
//restituisce un ID univoco per gestire la registrazione
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
return md5(uniqid(mt_rand(), true));
}
function reg_check_data(&$data){
global $_CONFIG;
$errors = array();
foreach($data as $field_name => $value){
$func = $_CONFIG['check_table'][$field_name];
if(!is_null($func)){
$ret = $func($value);
if($ret !== true)
$errors[] = array($field_name, $ret);
}
}
return count($errors) > 0 ? $errors : true;
}
function reg_confirm($id){
global $_CONFIG;
$query = mysql_query("
UPDATE ".$_CONFIG['table_utenti']."
SET temp='0'
WHERE uid='".$id."'");
return (mysql_affected_rows () != 0) ? REG_SUCCESS : REG_FAILED;
}
?>