3

如何在 Joomla 1.5 中自动登录用户。我正在使用这段代码:

global $mainframe;

$db =& JFactory::getDBO();  

$query = ‘SELECT `id`, `password`, `gid`’. ‘ FROM `#__users`’. ‘ WHERE username=’ . $db->Quote( JRequest::getVar(‘username’, null) ). ‘   AND password=’ . `enter code here` $db->Quote( JRequest::getVar(‘passw’, null) );

$db->setQuery( $query );
$result = $db->loadObject();

    if($result) {
       JPluginHelper::importPlugin(‘user’);
       $response->username = JRequest::getVar(‘username’, null);
       $result = $mainframe->triggerEvent(‘onLoginUser’, array((array)$response, $options));
    }

$mainframe->redirect(‘XXXXXXXXXXXX’);

我哪里做错了?

4

2 回答 2

1

添加此代码的顶部,它将解决问题

jimport(‘joomla.user.helper’);
于 2012-07-26T12:37:08.537 回答
-1

// Akram abbasi 的自动登录自定义

$mainframe = JFactory::getApplication();
$credentials = array(); 
$credentials['username']  =  $app->input->get('username', '', 'string');
$credentials['password']  = $app->input->get('password',  '', 'raw');
$mainframe->login($credentials);
//$mainframe->redirect(JRoute::_('index.php', false));
于 2015-03-06T10:51:53.320 回答