TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-09-2009, 12:32 PM   #1 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default Need help with a User class

Recently I'm working on a User class. I need some help with this class to get it on track.

For example, I want a user to get logged in, how would I do this? Do I need to pass the HTML form to the login() function? Or do I need to pass all variables (like email and password) as variables, or?

Also, how to correctly interact with the Database class I've written? Should I do something like this?

PHP Code:
private $m_pConn;

function 
__construct()
{
    
$m_pConn = new Database();

Or am I thinking in the wrong way? Oh well, someday I will fully understand the OOP way of thinking. Thanks in advance for your replies.

This is what I have thus far:

PHP Code:
class User
{
    private 
$m_iId;
    private 
$m_szName;
    private 
$m_szEmail;
    
    private 
$m_bLoggedIn;
    
    function 
login()
    {
        
// Do login here.
    
}
    
    function 
get_id()
    {
        return 
$this->m_iId;
    }
    
    function 
get_name()
    {
        return 
$this->m_szName;
    }
    
    function 
get_email()
    {
        return 
$this->m_szEmail;
    }
    
    function 
is_logged_in()
    {
        return (bool) 
$m_bLoggedIn;
    }

maZtah is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy to Modify Login Script with Hierarchical User Permissions and XML Account File Wildhoney Script Giveaway 4 05-04-2011 06:11 AM
Please rip my code to pieces: generic user management class adamsargant Advanced PHP Programming 6 09-12-2008 11:22 AM
[Tutorial] Basic tutorial about class basics Tanax Absolute Beginners 14 07-24-2008 01:37 PM
PHP5 Classes A to Z Part 1 quantumkangaroo Advanced PHP Programming 11 04-01-2008 04:21 AM
Tutorial: PHP and OOP, a beginners guide Village Idiot Tips & Tricks 0 09-06-2007 04:23 PM


All times are GMT. The time now is 12:32 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design