Viewing topic:User n Pass registration
Page:
1
26-04-2008 - 16:00
Hello,
I like your user and registration tutorial very much, but i have a few questions.
1)How do i make only certain pages available for registered users only ?
2)How can i include an activation email link when someone registers ?
Thanks
I like your user and registration tutorial very much, but i have a few questions.
1)How do i make only certain pages available for registered users only ?
2)How can i include an activation email link when someone registers ?
Thanks
27-04-2008 - 10:49
Hey kova welcome to Combined Minds! 
1) You learned that you need to start the session with session_start on each page you want to use the logged in user. Then it's quite easy. The $_SESSION['user_id'] only exists when the user is logged in. So just check with if(isset($_SESSION['user_id'])) (or another session name if it's called different of course)
2) That's a bit more difficult. You start with a new table field, a field named "active". This field can be either 1 (one) or 0 (zero). 1 means the user is active, 0 means he's not.
When registering you set the active field on zero by default. And send an email with a link with an unique identifier (something like md5($user_id)). The page specified in the link, something like activate.php will check the unique string and if the user of the unique string is found you set active to one.
Example activation link:
activate.php?key=asdfvdvdbfvv34f3r87vnerv9urenvdn0r
Save the activation link also in a new field (something like field "activation"
. And make sure the link isn't guessable. 
Bit sloppy explenaition... Just woke up so i'm sleapy

1) You learned that you need to start the session with session_start on each page you want to use the logged in user. Then it's quite easy. The $_SESSION['user_id'] only exists when the user is logged in. So just check with if(isset($_SESSION['user_id'])) (or another session name if it's called different of course)
2) That's a bit more difficult. You start with a new table field, a field named "active". This field can be either 1 (one) or 0 (zero). 1 means the user is active, 0 means he's not.
When registering you set the active field on zero by default. And send an email with a link with an unique identifier (something like md5($user_id)). The page specified in the link, something like activate.php will check the unique string and if the user of the unique string is found you set active to one.
Example activation link:
activate.php?key=asdfvdvdbfvv34f3r87vnerv9urenvdn0r
Save the activation link also in a new field (something like field "activation"
. And make sure the link isn't guessable. 
Bit sloppy explenaition... Just woke up so i'm sleapy
Page:
1
Reply to topic
Reply to topic

