ravint
07-12-2002, 19.23.42
ma come si fa un cookie
ho notato che esistono tanti modi, ogni modo deve essere uguale al tipo di script che crei, dico bene o sono fuori strada???
nel mio caso come devo fare?????
qui di seguito alcuni esempi dello codice gia in possesso:
questa e' la tabella:
create table user (
user_id int not null auto_increment primary key,
user_name text,
real_name text,
email text,
password text,
remote_addr text,
confirm_hash text,
is_confirmed int not null default 0
quest'altra e' una parte dello script:
function user_login($user_name,$password) {
global $feedback;
if (!$user_name || !$password) {
$feedback .= ' ERRORE - User Name o password errate!!!';
return false;
} else {
$user_name=strtolower($user_name);
$password=strtolower($password);
$sql="SELECT * FROM user WHERE user_name='$user_name' AND password='". md5($password) ."'";
$result=db_query($sql);
if (!$result || db_numrows($result) < 1){
$feedback .= ' ERRORE - User Name non trovato o password errata ';
return false;
} else {
if (db_result($result,0,'is_confirmed') == '1') {
user_set_tokens($user_name);
$feedback .= ' Bentornato! - Accesso consentito';
return true;
} else {
$feedback .= ' ERRORE - Non hai confermato il tuo accout, attendi l'e-mail di conferma';
return false;
}
}
}
}
function user_logout() {
setcookie('user_name','',(time()+2592000),'/','',0);
setcookie('id_hash','',(time()+2592000),'/','',0);
}
function user_set_tokens($user_name_in) {
global $hidden_hash_var,$user_name,$id_hash;
if (!$user_name_in) {
$feedback .= ' ERROR - User Name Missing When Setting Tokens ';
return false;
}
$user_name=strtolower($user_name_in);
$id_hash= md5($user_name.$hidden_hash_var);
setcookie('user_name',$user_name,(time()+2592000), '/','',0);
setcookie('id_hash',$id_hash,(time()+2592000),'/','',0);
}
function user_confirm($hash,$email) {
/*
Call this function on the user confirmation page,
which they arrive at when the click the link in the
account confirmation email
*/
global $feedback,$hidden_hash_var;
quindi cosa devo mettere nelle pagine riservate che l'utente registrato vuole vedere???
come imposto il link o il menu??
ciao
Massimo
*************
__________________
Se vado a letto con tua moglie, siamo parenti? :confused:
No!!, siamo pari :D
ho notato che esistono tanti modi, ogni modo deve essere uguale al tipo di script che crei, dico bene o sono fuori strada???
nel mio caso come devo fare?????
qui di seguito alcuni esempi dello codice gia in possesso:
questa e' la tabella:
create table user (
user_id int not null auto_increment primary key,
user_name text,
real_name text,
email text,
password text,
remote_addr text,
confirm_hash text,
is_confirmed int not null default 0
quest'altra e' una parte dello script:
function user_login($user_name,$password) {
global $feedback;
if (!$user_name || !$password) {
$feedback .= ' ERRORE - User Name o password errate!!!';
return false;
} else {
$user_name=strtolower($user_name);
$password=strtolower($password);
$sql="SELECT * FROM user WHERE user_name='$user_name' AND password='". md5($password) ."'";
$result=db_query($sql);
if (!$result || db_numrows($result) < 1){
$feedback .= ' ERRORE - User Name non trovato o password errata ';
return false;
} else {
if (db_result($result,0,'is_confirmed') == '1') {
user_set_tokens($user_name);
$feedback .= ' Bentornato! - Accesso consentito';
return true;
} else {
$feedback .= ' ERRORE - Non hai confermato il tuo accout, attendi l'e-mail di conferma';
return false;
}
}
}
}
function user_logout() {
setcookie('user_name','',(time()+2592000),'/','',0);
setcookie('id_hash','',(time()+2592000),'/','',0);
}
function user_set_tokens($user_name_in) {
global $hidden_hash_var,$user_name,$id_hash;
if (!$user_name_in) {
$feedback .= ' ERROR - User Name Missing When Setting Tokens ';
return false;
}
$user_name=strtolower($user_name_in);
$id_hash= md5($user_name.$hidden_hash_var);
setcookie('user_name',$user_name,(time()+2592000), '/','',0);
setcookie('id_hash',$id_hash,(time()+2592000),'/','',0);
}
function user_confirm($hash,$email) {
/*
Call this function on the user confirmation page,
which they arrive at when the click the link in the
account confirmation email
*/
global $feedback,$hidden_hash_var;
quindi cosa devo mettere nelle pagine riservate che l'utente registrato vuole vedere???
come imposto il link o il menu??
ciao
Massimo
*************
__________________
Se vado a letto con tua moglie, siamo parenti? :confused:
No!!, siamo pari :D