Page 1 of 1

redirect_to_alias() redirects to admin login :/

Posted: Wed Sep 10, 2008 5:13 pm
by unnamed7
Hi, what can be wrong with my code here ?
[php]
DoAction('login_form', $id, $params, $loginpage);
}
    $loginone = $params['login'];
$passone = md5($params['pass']);
$db = &$this->GetDB();
$query = "SELECT * FROM ".cms_db_prefix()."module_Clients WHERE login='$loginone'";
$result = $db->Execute($query);
if(!$result) die($db->ErrorMsg());
$row = $result->FetchRow();
$login = $row['login'];
$pass = $row['pass'];
$params['login'] = $row['login'];
if($login == $loginone && $pass == $passone){
    $_SESSION['logged'] = true;
$_SESSION['user'] = $login;
                redirect_to_alias($login);
}else{
echo "error";
}

?>
[/php]

when i comment  redirect_to_alias($login); and for example write echo $login; everything works fine, so, why  redirect_to_alias($login); redirects to admin area, but wont redirect to page ?
when i'am logged to admin panel it works fine...

cant figure it out, please help.
and sorry for my poor english :)

Re: redirect_to_alias() redirects to admin login :/

Posted: Wed Sep 10, 2008 6:11 pm
by NaN
Could you please give a short explanation what your'e trying to do?
I don't know in what context you use that code.
Is it a module, an UDT or a plugin?

Re: redirect_to_alias() redirects to admin login :/

Posted: Thu Sep 11, 2008 10:22 am
by unnamed7
it's a module, i just want to redirect to another (alias same as username) page after login :)

Re: redirect_to_alias() redirects to admin login :/

Posted: Thu Sep 11, 2008 4:35 pm
by NaN
Did you try $this->redirect_to_alias() ?

Re: redirect_to_alias() redirects to admin login :/

Posted: Thu Sep 11, 2008 8:16 pm
by unnamed7
if i try $this-> i get error
[php]Fatal error: Call to undefined method Clients::redirect_to_alias() in /home/users/test/public_html/inetic/modules/Clients/action.login_user.php on line 22[/php]

without $this->, redirect_to_alias works fine, but only when i'am logged to admin panel, something like this happend to my for example when i used CreateLink and had bad returnid... but  redirect_to_alias should work i think...

damn, maybe u know some workaround ? i just need to simply redirect to another page... simple, yet hard for me :/

Re: redirect_to_alias() redirects to admin login :/

Posted: Sun Sep 14, 2008 7:49 pm
by unnamed7
anyone ?

Re: redirect_to_alias() redirects to admin login :/

Posted: Mon Sep 15, 2008 3:25 am
by NaN
What is "Clients"?
How did you integrate that Module/Class?
I'm not that familiar with object oriented programming but if you use $this->GetDB or $this->DoAction you should also be able to use all functions that are in the module api.
I'm not sure at the moment but is redirect_to_alias a regular function of the module api?
If it is called from the frontend "directly" e.g. by a plugin it should work.
But if you're calling from a module try this:

$this->RedirectContent($content_id)

or this one:

$this->RedirectForFrontEnd ($id, $returnid, $action, $params)

(http://www.cmsmadesimple.org/apidoc/CMS ... ectContent)