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;
}
}