Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [php] login utente
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
erdottore
.revolution.

User info:
Registered: Jul 2004
Posts: 190 (0.02 al dì)
Location: SBT/MI
Corso: TS
Anno: 3
Time Online: 26 Days, 11:56:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

mi aggiungo a questo topic per chiedere una mano a qualcuno su come fare un script php con sessioni per il login e la gestione degli utenti, che si devono autenticare con user e password. Esiste un database con tutti gli user e le relative password. Lo script deve andare a loggare l'utente e mantenere attiva la connessione anche per le altre pagine che l'utente visiterà, tramite appunto le sessioni.
Una cosa del genere...


$q = "select pass from Utenti_at where user = '$username'";
$result = mysql_query($q,$conn);
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Username non valido
}


$dbarray = mysql_fetch_array($result);
$dbarray['pass'] = stripslashes($dbarray['pass']);
$password = stripslashes($password);


if($password == $dbarray['pass']){
return 0; //User e pass ok!
}
else{
return 2; //Password errata
}

__________________
¡El paraíso no es un lugar en donde se desea para ser ido, solamente una condición para vivir!

29-12-2005 13:35
Click Here to See the Profile for erdottore Click Here to See the Blog of erdottore Click here to Send erdottore a Private Message Find more posts by erdottore Add erdottore to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Drake83
Fan di Splinter

User info:
Registered: Nov 2003
Posts: 1631 (0.20 al dì)
Location: Garbagnate milanese
Corso: Tutto finito
Anno:
Time Online: 108 Days, 5:46:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by erdottore
mi aggiungo a questo topic per chiedere una mano a qualcuno su come fare un script php con sessioni per il login e la gestione degli utenti, che si devono autenticare con user e password. Esiste un database con tutti gli user e le relative password. Lo script deve andare a loggare l'utente e mantenere attiva la connessione anche per le altre pagine che l'utente visiterà, tramite appunto le sessioni.
Una cosa del genere...


Ciao....io uso un'altro approccio : faccio l'autenticazione di passwd e account in una sola query , se c'è un (solo) risultato [tramite mysql_num_rows($query)] creo il cookie inserendovi la md5 della passwd.

Tra l'altro io ho scritto tutto ciò ma la tua domanda qual'era?:D nn si capisce molto :D

__________________
"io non sono come gli altri Robin Hood, io non ballo coi lupi"
"ogni mattina come narciso si specchia nel ruscello retrovisore", "ci sono mille modi per chiamare dio...dio,allha,adta,arauffa,crisma..afjasf...tanto non ti risponde"

Corrado Guzzanti è il mio Dio.
Roberto Saviano eroe nazionale.

Last edited by Drake83 on 29-12-2005 at 14:22

29-12-2005 14:14
Click Here to See the Profile for Drake83 Click Here to See the Blog of Drake83 Click here to Send Drake83 a Private Message Find more posts by Drake83 Add Drake83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.67 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

$q = "select pass from Utenti_at where user = '$username'";


Dal pezzo di script che hai postato non si capisce se lo abbia già fatto, ma ricordati di filtrare quel $username e $password per il SQL Injection! Con uno str_replace() togli caratteri quali = ' " \ / e compagnia bella.

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

29-12-2005 14:28
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bloody
ex universitaria

User info:
Registered: Jan 2003
Posts: 1939 (0.23 al dì)
Location: milano trasferta
Corso: informatica
Anno: dottora :)
Time Online: 49 Days, 2:18:48 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Intervento del moderatore:
per chiarezza, ho splittato il post da quello degli editor di php, visto che è un argomento a sè (ed è più visibile)

usando le sessioni, un modo per tenere traccia dell'utente è fare una variabile di sessione che contenga il suo id, magari crittato :)

__________________
I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

29-12-2005 14:48
Click Here to See the Profile for Bloody Click Here to See the Blog of Bloody Click here to Send Bloody a Private Message Find more posts by Bloody Add Bloody to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 14:38.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.053 seconds (58.26% PHP - 41.74% MySQL) con 25 query.