- Home
- Categorie
- Coding e Sistemistica
- Coding
- Modificare metodo di registrazione nel forum
-
Modificare metodo di registrazione nel forum
Salve ho installato su database un forum già fatto, ma ha una pecca che vorrei risolvere, la registrazione avviene subito e invece io voglio che la registrazione avvenga attivandola via mail, come posso fare? grazie
questo è il file di registrazione: da notare che una mail viene inviata ma non ha nessun link di attivazione poichè appunto viene inviata a registrazione già avvenuta
[PHP]<?php
require_once "includes/config.php";
require_once "includes/mysql_connect.php";
require_once "includes/getsett.php";
require_once "includes/funzioni.php";
require_once "includes/funzioni_testi.php";
if(trim($arr_impostazioni['lingua'])=="" || !is_dir("lang/".$arr_impostazioni['lingua'])){ $arr_impostazioni['lingua']="ita"; }
require_once "lang/".$arr_impostazioni['lingua']."/registrazione.php";
if(user_esistente=="si"){
if(my_bannato=="si"){
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td class="testo12">".sei_bannato.".<br /><br />
<a href="mailto:".$arr_impostazioni['mailsito']."">".contatta_admin.".</td>
</tr>
</table>";
}else{
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td class="testo12">".err_loggato.".</td>
</tr>
</table>";
}
}else{
$step=(ereg("[1-4]",$_GET['step'])) ? (int)$_GET['step'] : (int)$_POST['step'];
if($step==2){ //STEP 2 ---------------------------------------------------------------------
define('titolo_pagina',' - '.registrazione_titolo1);
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else if($step==3){ //STEP 3 ---------------------------------------------------------------------
define('titolo_pagina',' - '.registrazione_titolo2);
$_POST['newmail']=togli_char_spec($_POST['newmail']);
$_POST['newuser']=togli_char_spec($_POST['newuser']);
require_once "header.php";
if(!checkmail($_POST['newmail'])){
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".errore."</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">".err_mail."!</span></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" value="".$_POST['newuser']."" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" value="".$_POST['newmail']."" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else{
$q_useresiste=quera("SELECT nome,mail FROM ".$tblprefix."users WHERE nome='".mysql_escape_string($_POST['newuser'])."' OR mail='".mysql_escape_string($_POST['newmail'])."' LIMIT 1");
if(mysql_num_rows($q_useresiste)>0){
$arr_useresistente=mysql_fetch_assoc($q_useresiste);
if($_POST['newuser']==$arr_useresistente['nome']){ $stringa_esiste.="• username<br />"; }
if($_POST['newmail']==$arr_useresistente['mail']){ $stringa_esiste.="• e-mail<br />"; }
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".errore."</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">".err_dati_usati.":<br />
$stringa_esiste</span></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" value="".$_POST['newuser']."" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" value="".$_POST['newmail']."" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else if(!isset($_POST['newuser']) || trim($_POST['newuser'])=="" || !isset($_POST['newpsw']) || trim($_POST['newpsw'])==""){
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".errore."</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">".err_campi."!</span></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" value="".$_POST['newuser']."" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" value="".$_POST['newmail']."" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else if(trim($_POST['newpsw'])!=trim($_POST['newcpsw'])){
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".errore."</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">".err_psw."!</span></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" value="".$_POST['newuser']."" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" value="".$_POST['newmail']."" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else if(strlen(trim($_POST['newuser']))>20 || strlen(trim($_POST['newmail']))>40 || strlen(trim($_POST['newpsw']))>20){
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".errore."</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">".err_lunghezza.".</span></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".inserisci_dati.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".username.":</span></div></td>
<td width="65%" class="tabstat"><input name="newuser" type="text" id="newuser" size="45" maxlength="20" value="".$_POST['newuser']."" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".password.":</div>
</td>
<td class="tabstat"><input name="newpsw" type="password" id="newpsw" size="45" maxlength="20" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".cpassword.":</div></td>
<td class="tabstat"><input name="newcpsw" type="password" id="newcpsw" size="45" maxlength="20" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".email.":</div>
</td>
<td class="tabstat"><input name="newmail" type="text" id="newmail" size="45" maxlength="40" value="".$_POST['newmail']."" />
</td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="3" />
<input name="prosegui" type="button" class="pulsinvia" value="".avanti_form."" onClick="convalida();" />
</div></td>
</tr>
</form>
</table>";
}else{
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="registrazione.php" method="post" enctype="multipart/form-data" name="registra">
<tr>
<td colspan="2" class="tabstat"><div class="testo12"><strong>".profilo.":</strong></div></td>
</tr>
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo12"><span class="testo12">".luogo.":</span></div></td>
<td width="65%" class="tabstat"><input name="luogo" type="text" id="luogo" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".homepage.":</div>
</td>
<td class="tabstat"><input name="sito" type="text" id="sito" size="45" />
</td>
</tr>
<tr>
<td class="tabstat"><div align="right">MSN:</div></td>
<td class="tabstat"><input name="msn" type="text" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right">ICQ:</div></td>
<td class="tabstat"><input name="icq" type="text" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right">AIM:</div></td>
<td class="tabstat"><input name="aim" type="text" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right">Yahoo:</div></td>
<td class="tabstat"><input name="yahoo" type="text" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right">Skype:</div></td>
<td class="tabstat"><input name="skype" type="text" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo12">".nascita.":</div></td>
<td class="tabstat"><span class="testo11">".giorno.":
<select name="nascitagiorno"> ".select_giorni('')."</select>
".mese.": <select name="nascitamese">".select_mesi('')."</select>
".anno.":
<select name="nascitaanno"> ".select_anni('')."</select></span></td>
</tr>
<tr>
<td valign="top" class="tabstat"><div align="right" class="testo12">".firma.":<br /><span class="testo10">(".firma_max.": ".$arr_impostazioni['maxfirma'].")</span></div></td>
<td class="tabstat"><textarea name="firma" cols="40" rows="5" id="firma" onKeyDown="if(this.value.length>".$arr_impostazioni['maxfirma'].")this.value=this.value.substr(0,".$arr_impostazioni['maxfirma'].")"></textarea></td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="step" type="hidden" id="step" value="4" />
<input name="newuser" type="hidden" value="".$_POST['newuser']."" />
<input name="newpsw" type="hidden" value="".$_POST['newpsw']."" />
<input name="newmail" type="hidden" value="".$_POST['newmail']."" />
<input type="submit" class="pulsinvia" value="".prosegui_form."" />
</div></td>
</tr>
</form>
</table>";
}
}
}else if($step==4){ //STEP 4 ---------------------------------------------------------------------
define('titolo_pagina',' - '.registrazione_titolo3);
$_POST['newmail']=togli_char_spec($_POST['newmail']);
$_POST['newuser']=togli_char_spec($_POST['newuser']);
$_POST['firma']=togli_char_spec($_POST['firma']);
$_POST['luogo']=togli_char_spec($_POST['luogo']);
$_POST['sito']=togli_char_spec($_POST['sito']);
$_POST['msn']=togli_char_spec($_POST['msn']);
$_POST['icq']=togli_char_spec($_POST['icq']);
$_POST['aim']=togli_char_spec($_POST['aim']);
$_POST['yahoo']=togli_char_spec($_POST['yahoo']);
$_POST['skype']=togli_char_spec($_POST['skype']);if(trim($_POST['firma'])!=""){
$firma=mysql_escape_string($_POST['firma']);
}
quera("INSERT INTO ".$tblprefix."users (nome,psw,ip,mail,firma,datareg,nascita_g,nascita_m,nascita_a,luogo,sito,msn,icq,aim,yahoo,skype)
VALUES ('".mysql_escape_string($_POST['newuser'])."','".md5($_POST['newpsw'])."','".$_SERVER['REMOTE_ADDR']."','".mysql_escape_string($_POST['newmail'])."','$firma','".time()."','".$_POST['nascitagiorno']."','".$_POST['nascitamese']."','".$_POST['nascitaanno']."','".mysql_escape_string($_POST['luogo'])."','".mysql_escape_string($_POST['sito'])."','".mysql_escape_string($_POST['msn'])."','".mysql_escape_string($_POST['icq'])."','".mysql_escape_string($_POST['aim'])."','".mysql_escape_string($_POST['yahoo'])."','".mysql_escape_string($_POST['skype'])."')");
quera("UPDATE ".$tblprefix."stats SET tot_users=tot_users+1, ultimo_userid='".mysql_insert_id()."'");
setcookie("denome",$_POST['newuser'],time()+(86400365),"/");
setcookie("depsw",md5($_POST['newpsw']),time()+(86400365),"/");
$corpo=mail_benvenuto." ".$_POST['newuser'].",\n\n".mail_reg_completata."!\n\n
".mail_staff."! :)\n\n\n".$arr_impostazioni['urlforum'];
mandamail($_POST['newmail'],$arr_impostazioni['titoloforum']." - ".mail_oggetto."!",$corpo);
define('in_reg_step4','si');
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td width="100%" class="tabstat"><span class="testo12">".mail_benvenuto." <strong>".$_POST['newuser']."</strong>, ".mail_reg_completata."!<br />
<br />
".ora_puoi.".<br />
".puoi_modificare.".</span> <img src="img/empty.gif" border="0" onload="concalma('index.php','4000');" /></td>
</tr>
</table>";
}else{ //STEP 1 ---------------------------------------------------------------------
define('titolo_pagina',' - '.registrazione_titolo4);
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td class="tabstat"><div class="testo12"><strong>".regolamento.":</strong></div></td>
</tr>
<tr>
<td class="tabstat"><span class="testo12">1) ".regola1.".<br /><br />
2) ".regola2.".<br /><br />
3) ".regola3.".<br /><br />
4) ".regola4.".<br /><br />
5) ".regola5.".<br /><br />
6) ".regola6.".<br /><br />
7) ".regola7.".</span></td>
</tr>
<tr>
<td class="tabstat"><div align="center" class="testo12">
<input name="prosegui" type="button" class="pulsinvia" onClick="window.location='registrazione.php?step=2'" value=" ".accetto_form." " />
</div></td>
</tr>
</table>";
}
}
if($_GET['debug']=="y"){ debugging(); }
require_once "copy.php";
?>[/PHP]
-
Ok, se il forum era già fatto dimmi che forum è così si fa prima
keiske
-
@Privacy-Impresa said:
Ok, se il forum era già fatto dimmi che forum è così si fa prima
keiske
il forum in questione è deforum ultima versione
spero fosse questa la cosa che volevi sapere.
-
al momento quel forum non supporta l'autenticazione via mail... e eviterei di mettere le mani dietro al codice... ma scusa... ma mettere phbb3 che è facilissimo da installare ed è un prodotto free decisamente migliore di questo?
keiske
edit: Dal forum di sviluppo di quella board:
"Ciao, purtroppo è da un po' di tempo che ho lasciato lo sviluppo di questo forum e non so darti indicazioni troppo precise."No dico, hai preso pure una board che nessuno sviluppa più
-
@Privacy-Impresa said:
al momento quel forum non supporta l'autenticazione via mail... e eviterei di mettere le mani dietro al codice... ma scusa... ma mettere phbb3 che è facilissimo da installare ed è un prodotto free decisamente migliore di questo?
keiske
edit: Dal forum di sviluppo di quella board:
"Ciao, purtroppo è da un po' di tempo che ho lasciato lo sviluppo di questo forum e non so darti indicazioni troppo precise."No dico, hai preso pure una board che nessuno sviluppa più
pensa che l'ho pure in dotazione su altervista ma è complicato mentre questo ha una grafica carina è semplice con le funzioni che voglio io, insomma tu dici che non è da metterci le mani?
-
complicato phbb3? L'ho scaricato ieri a pranzo e dopo mezz'ora era su... ieri sera già l'avevo totalmente modificato per renderlo identico al layout del mio sito... ci metterai un'ora in più, ma l'installazione è una procedura click to click in 5 passaggi...
keiske
-
@Privacy-Impresa said:
complicato phbb3? L'ho scaricato ieri a pranzo e dopo mezz'ora era su... ieri sera già l'avevo totalmente modificato per renderlo identico al layout del mio sito... ci metterai un'ora in più, ma l'installazione è una procedura click to click in 5 passaggi...
keiske
ehm ch dire bravo, io non saprei proprio da dove partire, appena installato non mi faceva manco vedere i topic perchè dovevo impostare i permessi o una roba del genere, e poi è pieno di funzioni, magari se m spieghi qualcosina forse ci penso
-
qualcuno riesce ad aiutarmi per modificare quella registrazione, grazie.:)
-
Aggiungi 2 campi nella tabella uno sarà il codice di attivazione e uno lo stato dell'account se attivo o no. Generi un codice random e lo invi tramite email...
-
oppure anche solo un campo che all'iscrizione è codice di attivazione e dopo l'attivazione diventi 1... se non clicca per confermarsi al primo login controlli se il codice è uguale a 1, se non lo è non si è attivato... gli dai modo di farsi rispedire una mail estraendo il codice di attivazione...
keiske
-
innanzitutto molte grazie a tutti e due che mi avete risposto, questo forum mi piace molto e spero che con il vostro aiuto di risolvere questa cosa, il fatto è che di php-mysql non ne so quasi nulla, per questo vi chiedo gentilmente se potreste postarmi il codice da implementare nel file, ancora grazie sapevo di poter contare su di voi!:)
-
I passaggi sono:
-
Crea nel database un campo chiamato "attivazione" nella tabella degli utenti
-
Nella pagina che serve per registrarsi devi cercare la query MYSQL e postarla così ti possiamo dire come modificarla...
keiske
-
-
@Privacy-Impresa said:
I passaggi sono:
-
Crea nel database un campo chiamato "attivazione" nella tabella degli utenti
-
Nella pagina che serve per registrarsi devi cercare la query MYSQL e postarla così ti possiamo dire come modificarla...
keiske
ciao keiske la pagina di registrazione l'ho già postata sopra nel primo messaggio però quello che tu chiedi forse è questo passaggio?
[PHP]if(trim($_POST['firma'])!=""){
$firma=mysql_escape_string($_POST['firma']);
}
quera("INSERT INTO ".$tblprefix."users (nome,psw,ip,mail,firma,datareg,nascita_g,nascita_m,nascita_a,luogo,sito,msn,icq,aim,yahoo,skype)
VALUES ('".mysql_escape_string($_POST['newuser'])."','".md5($_POST['newpsw'])."','".$_SERVER['REMOTE_ADDR']."','".mysql_escape_string($_POST['newmail'])."','$firma','".time()."','".$_POST['nascitagiorno']."','".$_POST['nascitamese']."','".$_POST['nascitaanno']."','".mysql_escape_string($_POST['luogo'])."','".mysql_escape_string($_POST['sito'])."','".mysql_escape_string($_POST['msn'])."','".mysql_escape_string($_POST['icq'])."','".mysql_escape_string($_POST['aim'])."','".mysql_escape_string($_POST['yahoo'])."','".mysql_escape_string($_POST['skype'])."')");
quera("UPDATE ".$tblprefix."stats SET tot_users=tot_users+1, ultimo_userid='".mysql_insert_id()."'");
setcookie("denome",$_POST['newuser'],time()+(86400365),"/");
setcookie("depsw",md5($_POST['newpsw']),time()+(86400365),"/");
$corpo=mail_benvenuto." ".$_POST['newuser'].",\n\n".mail_reg_completata."!\n\n
".mail_staff."! :)\n\n\n".$arr_impostazioni['urlforum'];
mandamail($_POST['newmail'],$arr_impostazioni['titoloforum']." - ".mail_oggetto."!",$corpo);
define('in_reg_step4','si');
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td width="100%" class="tabstat"><span class="testo12">".mail_benvenuto." <strong>".$_POST['newuser']."</strong>, ".mail_reg_completata."!<br />
<br />
[/PHP]
-
-
Allora, intanto accedi al db mysql e crea un campo nella tabella
$tblprefix."users
chiamalo: "attivazione"
Dopo di che la query sopra la cambi in:
$codice = "1111";
quera("INSERT INTO ".$tblprefix."users (nome,psw,ip,mail,attivazione,firma,datareg,nascita_g,nascita_m,nascita_a,luogo,sito,msn,icq,aim,yahoo,skype)
VALUES ('".mysql_escape_string($_POST['newuser'])."','".md5($_POST['newpsw'])."','".$_SERVER['REMOTE_ADDR']."','".mysql_escape_string($_POST['newmail'])."','$codice','$firma','".time()."','".$_POST['nascitagiorno']."','".$_POST['nascitamese']."','".$_POST['nascitaanno']."','".mysql_escape_string($_POST['luogo'])."','".mysql_escape_string($_POST['sito'])."','".mysql_escape_string($_POST['msn'])."','".mysql_escape_string($_POST['icq'])."','".mysql_escape_string($_POST['aim'])."','".mysql_escape_string($_POST['yahoo'])."','".mysql_escape_string($_POST['skype'])."')");Le modifiche sono sottolineate
Ovviamente prima devi crearlo il codice... quindi prima abbiamo aggiunto un valore a $codice (poi se funziona lo sostituiamo con una formula random). Calcola che non vedo tutto il codice, la variabile $codice dev'essere chiamata mentre gira il codice che ti registra.
Fatto questo abbiamo una pagina che ti registra e assegna oltre al resto anche il valore "1111" alla variabile $codice nel database al campo "attivazione"
Adesso devi aggiungere $codice nell'email che viene inviata a chi si iscrive.
Adesso arriva una email che ti dice: "grazie per esserti iscritto?"
Per andare avanti mi serve la pagina del login anche
keiske
-
allora grazie per la tua chiarezza nell'indicare tutti i passaggi, adesso quello che io ho fatto è stato quello di aggiungere le parti sottolineate al file registrazione ed ora ti posto login.php:
per vedere il file guardalo qui
-
[php]
$codice = "1111";
[/php]*
puoi mettere per esempio:
[php]
$codice = md5(microtime());
[/php]
per generarti 32 lettere*il file login fai cosi:
[php]
<?php
require_once "includes/config.php";
require_once "includes/mysql_connect.php";
require_once "includes/getsett.php";
require_once "includes/funzioni.php";
if(trim($arr_impostazioni['lingua'])=="" || !is_dir("lang/".$arr_impostazioni['lingua'])){ $arr_impostazioni['lingua']="ita"; }
require_once "lang/".$arr_impostazioni['lingua']."/login.php";
$actlog=(isset($_GET['actlog'])) ? $_GET['actlog'] : $_POST['actlog'];if($actlog=="entra"){
if(user_esistente=="si"){
if(my_bannato=="si"){
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr class="tabcat">
<td colspan="4" class="testo12">".sei_bannato.".<br /><br />
<a href="mailto:".$arr_impostazioni['mailsito']."">".contatta_admin.".</a></td>
</tr>
</table>";
}else{
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr class="tabcat">
<td colspan="4" class="testo12">".gia_loggato.".</td>
</tr>
</table>";
}
}else{
$username=mysql_escape_string($_POST['username']);
$passw=mysql_escape_string($_POST['passw']);
$username=str_replace("%","",$username);
$passw=str_replace("%","",$passw);
$q_l_entra=quera("SELECT id,nome,livello,attivazione FROM ".$tblprefix."users WHERE nome='$username' AND psw='".md5($passw)."' LIMIT 1");
if(mysql_num_rows($q_l_entra)==1){
$arr_entrato=mysql_fetch_assoc($q_l_entra);
if($arr_entrato['attivazione'] != '1')
die('Devi attivare l'account');
$l_id=$arr_entrato['id'];
$l_nome=$arr_entrato['nome'];
$l_livello=$arr_entrato['livello'];
//$rootcookie=$_SERVER['HTTP_HOST'];
//$rootcookie=str_replace("www.","",$rootcookie);
setcookie("denome","$l_nome",time()+(86400365),"/");
setcookie("depsw",md5($passw),time()+(86400365),"/");
quera("DELETE FROM ".$tblprefix."online WHERE ip='".$_SERVER['REMOTE_ADDR']."' LIMIT 1");
if(!isset($_POST['prov']) || trim($_POST['prov'])=="" || strpos($_POST['prov'],"resetpsw.php")!==false || strpos($_POST['prov'],"login.php")!==false || strpos($_POST['prov'],"registrazione.php")!==false){
$locain="index.php";
}else{
$locain=$_POST['prov'];
}
header("Location: $locain");
}else{
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo13">
".errore.": ".err_user_psw."!<br />
".cookie_abilitati.".</div></td>
</tr>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="login.php" method="post" name="login" id="login">
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo11">".username.":</div></td>
<td width="65%" class="tabstat"><input name="username" type="text" id="username" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo11">".psw.":</div></td>
<td class="tabstat"><input name="passw" type="password" id="passw" size="45" /></td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input type="hidden" name="actlog" value="entra" />
<input type="hidden" name="prov" value="".$_SERVER['HTTP_REFERER']."" />
<input type="submit" name="Submit2" value=" ".entra." " class="pulsinvia" />
</div></td>
</tr>
</form>
</table><br />
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<td colspan="2" class="tabstat"><div align="center">
<p class="testo11"><a href="resetpsw.php">".psw_persa."</a></p>
</div></td>
</tr>
</table><br />";
}
}}else if($actlog=="out"){
//$rootcookie=$_SERVER['HTTP_HOST'];
//$rootcookie=str_replace("www.","",$rootcookie);
setcookie("denome","",time()-(86400365),"/");
setcookie("depsw","",time()-(86400365),"/");
quera("DELETE FROM ".$tblprefix."online WHERE userid='".my_id."' LIMIT 1");
header("Location: index.php");}else{
require_once "header.php";
echo "<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<form action="login.php" method="post" name="login" id="login">
<tr>
<td width="35%" class="tabstat"><div align="right" class="testo11">".username.":</div></td>
<td width="65%" class="tabstat"><input name="username" type="text" id="username" size="45" /></td>
</tr>
<tr>
<td class="tabstat"><div align="right" class="testo11">".password.":</div></td>
<td class="tabstat"><input name="passw" type="password" id="passw" size="45" /></td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center" class="testo12">
<input name="actlog" type="hidden" id="actlog" value="entra" />
<input type="hidden" name="prov" value="".$_SERVER['HTTP_REFERER']."" />
<input type="submit" name="Submit2" value=" ".entra." " class="pulsinvia" />
</div></td>
</tr>
<tr>
<td colspan="2" class="tabstat"><div align="center">
<p class="testo11"><a href="resetpsw.php">".psw_persa."</a></p>
</div></td>
</tr>
</form>
</table>
<br />
<form action="registrazione.php">
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<tr>
<td class="tabstat"><div align="center" class="testo11">".non_registrato."?</div>
</td>
</tr>
<tr>
<td class="tabstat"><div align="center" class="testo12">
<input type="submit" name="Submit" value="".registrati."" class="pulsinvia" />
</div>
</td>
</tr>
</table>
</form>";
}
if($_GET['debug']=="y"){ debugging(); }
require_once "copy.php";
?>
[/php]*
*
-
Adesso impostiamo il controllo sulla variabile $codice / attivazione:
$q_l_entra=quera("SELECT id,nome,livello FROM ".$tblprefix."users WHERE nome='$username' AND psw='".md5($passw)."' LIMIT 1");
diventa
$q_l_entra=quera("SELECT id,nome,livello*,attivazione*
FROM ".$tblprefix."users WHERE nome='$username' AND psw='".md5($passw)."' LIMIT 1");In questo modo nell'array risultato della query abbiamo a disposizione anche il valore del campo attivazione
Ora dobbiamo vedere se attivazione è uguale a "1" che è il valore che imposteremo quando l'utente si è attivato (se non lo fa in quel campo ci sarà ancora il codice di attivazione che è di sicuro diverso da "1"
$arr_entrato=mysql_fetch_assoc($q_l_entra);
$l_id=$arr_entrato['id'];
$l_nome=$arr_entrato['nome'];
$l_livello=$arr_entrato['livello'];Sfruttiamo l'assoc che c'è già e ci garantisce anche che il controllo sul valore di attivazione lo faremo solo se l'utente esiste e ha messo la password giusta, e aggiungiamo:
$l_attivazione=$arr_entrato['attivazione'];A questo punto dobbiamo prevedere una casistica totalmente diversa da quelle che hai tu nel ciclo if else della pagina...
Infatti il tuo ciclo si basa sul fatto che la query di login abbia 1 risultato (e ti fa entrare).
Se la query non ha 1 risultato scatta un else if che chiede se è impostata per caso la variabile $act_logout e infine una terza opzione che indica che non c'è 1 risultato e nemmeno $act_logoutNoi dobbiamo metterci prima del riconoscimento iniziale, ma dopo il controllo del risultato positivo
if(mysql_num_rows($q_l_entra)==1){
$arr_entrato=mysql_fetch_assoc($q_l_entra);
$l_id=$arr_entrato['id'];
$l_nome=$arr_entrato['nome'];
$l_attivazione=$arr_entrato['attivazione'];
if($l_attivazione == '1') {
.
.
.
.
.
<table width="880" border="0" align="center" cellpadding="5" cellspacing="1" class="tabcat">
<td colspan="2" class="tabstat"><div align="center">
<p class="testo11"><a href="resetpsw.php">".psw_persa."</a></p>
</div></td>
</tr>
</table><br />";
}
} else {
header("Location: index.php");
}
}questa aggiunta controlla dopo il primo if e l'assegnazione a variabili dei valori estratti, se $l_attivazione == '1'.
Se lo è va avanti col login, tutto a posto. Se non lo è ricarica la index.php.Se riesci a far funzionare la cosa fin qui poi possiamo personalizzare il ritorno sulla index.php passando un messaggio che dica che l'account non è attivato e per questo non l'hai fatto entrare
ovviamente il tutto funziona se hai creato quel campo che ti ho detto nella tabella mysql, di tipo varchar con 200 caratteri di spazio assegnato
keiske
edit: adesso cava quel file txt subito, che è il miglior modo per sbandierare ai 4 venti come effettui le chiamate al db esponendoti a rischi
-
aiutoooo:o
non capisco più nulla, ma il messaggio di thedakita è giusto o non devo seguire quello che mi dice di fare?
-
Dovrebbe essere giusto, credo non abbia visto che ho postato prima di lui
-
Sono giusti tutti e due... nel suo caso ha aggiunto il campo alla query come me... poi gestisce la cosa con un controllo che porta a un die(), nel mio caso un controllo if che chiama un header().
Ma col die() poi come gestisci la cosa dark? Il tipo che non ha attivato deve ricaricare il sito manualmente, mentre col mio sistema lo rimandiamo alla index.php e poi imposteremo un messaggio che lo aiuti a risolvere il problema...
keiske