i used this tutorial from spoono http://www.pixel2life.com/tutorials/count/...gnup_and_login/ , and this is my question , is there a way to let let the script include certain files only if they logged in successfully? like maybe a user control panel , or profile settings?
User Login Question
Started by Stealth the damager, Nov 30 2006 12:58 AM
4 replies to this topic
#1
Posted 30 November 2006 - 12:58 AM
#2
Posted 30 November 2006 - 02:19 AM
Yes.
The way i'd do it is make a field that is set to "on" "off" and is updated whenever a user logs in/out. When they log in it's set to on...and when they're logged out it's set to off. Then just use an if statement to check if they're logged in or not.
The way i'd do it is make a field that is set to "on" "off" and is updated whenever a user logs in/out. When they log in it's set to on...and when they're logged out it's set to off. Then just use an if statement to check if they're logged in or not.
#3
Posted 30 November 2006 - 11:09 AM
alright so do i make this on and off fields in mysql or a variable
#4
Posted 30 November 2006 - 05:01 PM
In building my own user system, I've based alot of functions and methods off the IPBSDK (so technically, I'm basing it off IPB in the first place, lol). I use a method like this.
I use a class for this, which I'd believe you should to.
If you'd like the full class I have, I can PM you it. It's goign to be part of an open-source project anyways, so I don't mind.
(It's not completely developed anyways by the way.)
Here's a few snippets to deal with logging the user in and checking whether they are logged in currently.
Basically the class constructor establishes an attempt to login by the login() function later defined in the class, then I have an is_loggedin() function that returns whether the member's username is 'Guest' (which is the default that userdata() returns if the login could not be established).
Then, you can use the function like this. (Assuming you've established an instance of the class with the $member variable).
I use a class for this, which I'd believe you should to.
If you'd like the full class I have, I can PM you it. It's goign to be part of an open-source project anyways, so I don't mind.
(It's not completely developed anyways by the way.)
Here's a few snippets to deal with logging the user in and checking whether they are logged in currently.
function Member(){
// Grab Userdata
$username = (@$_SESSION['username']) ? @$_SESSION['username'] : @$_COOKIE['username'];
$password = (@$_SESSION['password']) ? @$_SESSION['password'] : @$_COOKIE['password'];
$this->user = $this->userdata($username, $password);
if($this->user['username'] != 'Guest') $this->login($this->user['username'], $this->user['password']);
}
function is_loggedin(){
return ($this->user['username'] != 'Guest') ? true : false;
}
Basically the class constructor establishes an attempt to login by the login() function later defined in the class, then I have an is_loggedin() function that returns whether the member's username is 'Guest' (which is the default that userdata() returns if the login could not be established).
Then, you can use the function like this. (Assuming you've established an instance of the class with the $member variable).
if($member->is_loggedin()) include('member_script.php');
Quite simple really. Edited by Demonslay, 30 November 2006 - 05:04 PM.
#5
Posted 02 December 2006 - 03:32 PM
aight cool , thanks alot ima try that
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
