Oppure

Loading
25/12/08 20:10
ale537
ciao a tutti.

mi servirebbe creare un modulo di login e di registrazione con conferma e mail sul mio sito ma non so come fare.
ho letto varie guide e scaricato vari script ma tutti mi davano qualche problema.

ora sto provando con questo ma non riesco a fare la registrazione anke se come admin riesco ad accedere..

qui ci sono tutti i file dello script
startdownload.filefront.com/12767729//cf25079d3f5321928016ef0f1ccdea70d02d25e0dfdf97d80cdd384c8b712da9496b53c756953a25//…=

qualcuno mi può dire dove sbaglio e come fare??
Ultima modifica effettuata da ale537 25/12/08 20:11
aaa
26/12/08 7:33
mc
Non ho guardato gli script; ma ti do' una traccia ....

File: login.php
-Se la sessione è settata, l'utente è loggato; reindirizzalo alla pagina protetta.
-Se no, stampa il form di login.
-Se la sessione non è settata e $_POST lo è, leggi password e user. Fai una query sul database, del tipo "SELECT * FROM tabella_utenti WHERE nome_utente="nome_utente_via_post" AND password="password_utente_via_post" LIMIT 1"
-Se la query restituisce una riga, ok l'utente esiste, setta le variabili sessione correttamente e reindirizzalo alla pagina protetta.
-Se no, stampa errore.

File: register.php
-Se $_GET non è settato; stampa form di registrazione, crea captcha, salva valore captcha su file.
-Se no, leggi i dati di registrazione, controlla che siano completi e validi, se no stampa errore.
Leggi il captcha, paragonalo a quello nel file, se non è corretto esci.
Inserisci un nuovo utente nel db, con i dati di registrazione, genera un nuovo id random, e inseriscilo nella tabella utenti_da_verificare, insieme al nome utente.
Invia una mail con l'id nuovo.

File: verifica.php
-Se $_GET è settato, leggi l'id, fai una query del tipo: "SELECT * FROM utenti_da_verificare WHERE id = id_via_get LIMIT 1"
-Se il numero di righe restituito è uguale ad uno, setta l'utente ad attivo e rimuovi la righa dal database.
-Se no, l'utente è giù attivo o inesistente.
Stampa errore.

File: pagina_protetta.php
-Se sessione è attiva, stampa pagina, se no stampa errore.
-Se sessione è attiva, ma utente è presente nella tabella utenti_da_attivare; stampa errore.
aaa
28/12/08 16:22
ale537
quando tento di registrarmi mi scrive
Parse error: syntax error, unexpected '}' in /home/hosting/a/ale/www/add.php on line 10

questo è il codice della pagina

<?PHP
//retrieve al the variables that had been submited by the from
$username1 = $HTTP_POST_VARS["username"];
$mailadres1 = $HTTP_POST_VARS["mailadres"];
$password1 = $HTTP_POST_VARS["password"];
$confirmpassword1 = $HTTP_POST_VARS["confirmpassword"];
//generate an random number for the user neede to activate there account
$actnum = rand( 1,999999999999);
//make sure that the activation number is positive (YES it can happen that the number is negatief.)
if ($actnum < 0){$actnum = $actnum + ($actnum*-2)}
//set the error variable to an empty string.
$error = "";

//check it the fields are not empty. if they are, append the error to the error variable ($error)
if ($username1 == ""){$error = "$error<li>No username given<BR>\n";}
if ($password1 == ""){$error = "$error<li>No password given<BR>\n";}
if ($mailadres1== ""){$error = "$error<li>No mailadres given<BR>\n";}
//check if the passwords match. if they don't append the error to the error variable ($errir)
if ($password1 <> $confirmpassword1) {$error = "$error<li>Passwords do not match<BR>\n";}

// let the config.php file make an database connection
include("config.php");
//make an query which checks if the username OR the emailadres ar in the database. if they are append an error.
$query = "Select * from signup where username='$username1' or mailadres='$mailadres1'";
$result = mysql_query($query); 
if ($row = mysql_fetch_array($result)){ 
if  ($row["username"] == $username1){$error = "$error<li>Your username is already used by another member<br>\n";}
if  ($row["mailadres"] == $mailadres1){$error = "$error<li>Your e-mail adres is already registrated in our database<br>\n";}
}

//if ther error variable is still an empty string. The summission was oke and you can start proccesing the submission
if ($error == ""){
//first we check wat the date and time is for the signupdate field
$datetime = date("d-m-Y G:i ");
//then we submit al this to the database
$query = "INSERT INTO signup (username, password, mailadres, actnum, userlevel, signupdate ,lastlogin, lastloginfail, numloginfail) VALUES ('$username1','$password1','$mailadres1','$actnum', '1', '$datetime','0','0','0')";  
$result = mysql_query($query); 
//and we make an (e-mail)message which contains the activation numer
//also possible is to put a link in that message like :
//http:// your url /activate.php?username=$username1&actnum=$actnum
//this would allow the user to direcly submit there activation without having to enter
//al the data again in the activation form
$message = "Activation number: $actnum";
// mail the message to the user
mail($mailadres1, "Sign up script user activationcode", $message, "From: Sign-up script");
// and redirect the user to the activation page
header("Location: activate.php"); 
}
else
//if $error is no longer a empty stirng there must have been error in the submision.
//here we echo an nice line which says there are a coulple of errors and we onpen an 
//unorder list (just the <ul> tag) and we prinnt the error. also we include a link back to the
//sign-upform
{echo "You could not be added to the database because of the following reasons<ul>
$error
</ul>Please return to <a href=\"signup.php\">signup form</a> and try again.";
}
?>
Ultima modifica effettuata da ale537 28/12/08 16:28
aaa
28/12/08 22:46
ale537
ho risolto un problema, mancava il punto e virgola ; alla fine di questa stringa

if ($actnum < 0){$actnum = $actnum + ($actnum*-2)}

e non mi mette più questo errore

Parse error: syntax error, unexpected '}' in /home/hosting/a/ale/www/add.php on line 10

quindi fin qui ho risolto, pereò non mi arriva la mail.. perchè??
aaa
29/12/08 17:43
Mte90
Prova usando context o notepad++.
sono programmi che colorano il codice e ti permettono di controllarlo per eventuali errori.
aaa
29/12/08 17:48
ale537
grazie di tutto ho risolto..

non era colpa del codice ma del sito.. su quello dove ero prima non mi permetteva di mandare le mail in uno dove sono ora si.

solo che me le classifica come posta indesiderata.. qualche consiglio??
aaa
31/12/08 14:50
Mte90
bèh lì si tratta di impostare la tua email XD
aaa
31/12/08 15:44
ale537
ke intendi???
ho uppato LO STESSO script in un altro sisto e funziona mentre nell'altro continua a non funzionare..

il php.ini del sito non lo posso mica cambiare...
aaa