Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP - problema col php
Forum - PHP - problema col php

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
ale537 (Normal User)
Newbie


Messaggi: 14
Iscritto: 25/12/2008

Segnala al moderatore
Postato alle 21:10
Giovedì, 25/12/2008
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
http://startdownload.filefront.com/12767729//cf25079d3f532 ...=

qualcuno mi può dire dove sbaglio e come fare??

Ultima modifica effettuata da ale537 il 25/12/2008 alle 21:11
PM Quote
Avatar
mc (Normal User)
Rookie


Messaggi: 52
Iscritto: 04/12/2008

Segnala al moderatore
Postato alle 8:33
Venerdì, 26/12/2008
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.

PM Quote
Avatar
ale537 (Normal User)
Newbie


Messaggi: 14
Iscritto: 25/12/2008

Segnala al moderatore
Postato alle 17:22
Domenica, 28/12/2008
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

Codice sorgente - presumibilmente Php

  1. <?PHP
  2. //retrieve al the variables that had been submited by the from
  3. $username1 = $HTTP_POST_VARS["username"];
  4. $mailadres1 = $HTTP_POST_VARS["mailadres"];
  5. $password1 = $HTTP_POST_VARS["password"];
  6. $confirmpassword1 = $HTTP_POST_VARS["confirmpassword"];
  7. //generate an random number for the user neede to activate there account
  8. $actnum = rand( 1,999999999999);
  9. //make sure that the activation number is positive (YES it can happen that the number is negatief.)
  10. if ($actnum < 0){$actnum = $actnum + ($actnum*-2)}
  11. //set the error variable to an empty string.
  12. $error = "";
  13.  
  14. //check it the fields are not empty. if they are, append the error to the error variable ($error)
  15. if ($username1 == ""){$error = "$error<li>No username given<BR>\n";}
  16. if ($password1 == ""){$error = "$error<li>No password given<BR>\n";}
  17. if ($mailadres1== ""){$error = "$error<li>No mailadres given<BR>\n";}
  18. //check if the passwords match. if they don't append the error to the error variable ($errir)
  19. if ($password1 <> $confirmpassword1) {$error = "$error<li>Passwords do not match<BR>\n";}
  20.  
  21. // let the config.php file make an database connection
  22. include("config.php");
  23. //make an query which checks if the username OR the emailadres ar in the database. if they are append an error.
  24. $query = "Select * from signup where username='$username1' or mailadres='$mailadres1'";
  25. $result = mysql_query($query);
  26. if ($row = mysql_fetch_array($result)){
  27. if  ($row["username"] == $username1){$error = "$error<li>Your username is already used by another member<br>\n";}
  28. if  ($row["mailadres"] == $mailadres1){$error = "$error<li>Your e-mail adres is already registrated in our database<br>\n";}
  29. }
  30.  
  31. //if ther error variable is still an empty string. The summission was oke and you can start proccesing the submission
  32. if ($error == ""){
  33. //first we check wat the date and time is for the signupdate field
  34. $datetime = date("d-m-Y G:i ");
  35. //then we submit al this to the database
  36. $query = "INSERT INTO signup (username, password, mailadres, actnum, userlevel, signupdate ,lastlogin, lastloginfail, numloginfail) VALUES ('$username1','$password1','$mailadres1','$actnum', '1', '$datetime','0','0','0')";  
  37. $result = mysql_query($query);
  38. //and we make an (e-mail)message which contains the activation numer
  39. //also possible is to put a link in that message like :
  40. //http:// your url /activate.php?username=$username1&actnum=$actnum
  41. //this would allow the user to direcly submit there activation without having to enter
  42. //al the data again in the activation form
  43. $message = "Activation number: $actnum";
  44. // mail the message to the user
  45. mail($mailadres1, "Sign up script user activationcode", $message, "From: Sign-up script");
  46. // and redirect the user to the activation page
  47. header("Location: activate.php");
  48. }
  49. else
  50. //if $error is no longer a empty stirng there must have been error in the submision.
  51. //here we echo an nice line which says there are a coulple of errors and we onpen an
  52. //unorder list (just the <ul> tag) and we prinnt the error. also we include a link back to the
  53. //sign-upform
  54. {echo "You could not be added to the database because of the following reasons<ul>
  55. $error
  56. </ul>Please return to <a href=\"signup.php\">signup form</a> and try again.";
  57. }
  58. ?>


Ultima modifica effettuata da ale537 il 28/12/2008 alle 17:28
PM Quote
Avatar
ale537 (Normal User)
Newbie


Messaggi: 14
Iscritto: 25/12/2008

Segnala al moderatore
Postato alle 23:46
Domenica, 28/12/2008
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è??

PM Quote
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Segnala al moderatore
Postato alle 18:43
Lunedì, 29/12/2008
Prova usando context o notepad++.
sono programmi che colorano il codice e ti permettono di controllarlo per eventuali errori.

PM Quote
Avatar
ale537 (Normal User)
Newbie


Messaggi: 14
Iscritto: 25/12/2008

Segnala al moderatore
Postato alle 18:48
Lunedì, 29/12/2008
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??

PM Quote
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Segnala al moderatore
Postato alle 15:50
Mercoledì, 31/12/2008
bèh lì si tratta di impostare la tua email XD

PM Quote
Avatar
ale537 (Normal User)
Newbie


Messaggi: 14
Iscritto: 25/12/2008

Segnala al moderatore
Postato alle 16:44
Mercoledì, 31/12/2008
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...

PM Quote
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Segnala al moderatore
Postato alle 18:57
Domenica, 04/01/2009
usando la stessa mail?
dovresti provare con un script php vuoto con inserito solo il codice per inviare l'email e vedere che succede.

PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo