I created a simple login form that posts data to _self and then I tried to check the credentials in order to log the user in.
The authenticating script looks like that:
if ($_POST['username'] && $_POST['password'] )
{
$db =& JFactory::getDBO();
$query = 'SELECT `id`'
. ' FROM #__users'
. ' WHERE username='.$_POST['username'];
$db->setQuery( $query );
$result = $db->loadResult();
if (!$result) {
echo 'User does not exist';
}
if($result && (USERNAME & PASS MATCH))
{
<< LOGIN AND REDIRECT TO CERTAIN PAGE >>
}
else
{
echo 'Invalid username or password';
}
}
In my simple php scripts, I used to set a SESSION variable to true when username and password match and thats how I considered a user to be logged in.
Here, what actions should I do? Is there a field in the database that is set when user is logged in? In other words, I want to log the user in and then redirect to another page.
Any suggestions?