I will paste a bt of code to show how things are working first then explain the problem...
Javascript (jQuery):
PHP
PHP:
Now the Issue:
the whole thing works fine as long as you click a link after you login and reload the page, but if you login, then logout straight away it throws you to the textResponse page instead of loading into the getLog division.
any idea's on how to counteract this and load the txtResponse into the right place?
Javascript (jQuery):
Code:
$(document).ready(function()
{
$('#loginf').ajaxForm({
beforeSubmit: function () { $('#getLog').html('<img src="/img/ajax-loader.gif">')},
target: '#getLog'
});
$('#logOut').ajaxForm({
beforeSubmit: function () { $('#getLog').html('<img src="/img/ajax-loader.gif">')},
target: '#getLog'
});
});
PHP:
$s_doLogin = $this->loginDisp();
if (isset($_POST['ajaxCall']) && $_POST['ajaxCall'] == '1'){
echo $s_doLogin;
die;
}
[B]public function loginDisp[/B](){
if ($this->obj_protect->showPage){
$curUser=$this->obj_protect->getUser();
$s_doLogin = "<span id=\"userLog\">Welcome<br>".$curUser."</span><br><br>\r\n";
$s_register = $this->obj_language->get("language/ucPanel");
$s_doLogin .= "<a href=\"/cp/\">".$s_register."</a><br>\r\n";
if ($this->obj_protect->checkAdmin() == "1"){
$s_doLogin .= "<a href=\"/adm/\">Admin</a><br>\r\n";
}
$s_doLogin .= $this->obj_layouts->doLogout();
} else {
$s_register = $this->obj_language->get("language/register");
$s_user = $this->obj_language->get("language/login/username");
$s_pass = $this->obj_language->get("language/login/pass");
$s_remMe = $this->obj_language->get("language/logRem");
$s_doLogin = $this->obj_layouts->doLogin($s_user, $s_pass, $s_remMe);
$curUser=$this->obj_protect->checkLogin();
$s_errMsg = $this->obj_language->get("language/userPass");
$s_curUser= str_replace("{userPass}", $s_errMsg ,$curUser);
$s_doLogin .= $s_curUser;
$s_doLogin .= "<br><a href=\"/index.php?p=register\">$s_register</a>";
}
return $s_doLogin;
}
PHP:
public function doLogin($s_user, $s_pass, $s_remember="Remember"){
$getURI = $_SERVER['REQUEST_URI'];
//"<form id=\"login\" name=\"login\" method=\"post\" action=\"".$getURI."\">
$s_return = "<form id=\"loginf\" method=\"post\" action=\"".$getURI."\" >
<label>".$s_user."
<input type=\"text\" name=\"username\" id=\"username\" title=\"required\" size=\"16\" />
</label>
<br />
<label>".$s_pass."
<input type=\"password\" name=\"password\" id=\"password\" title=\"required\" size=\"16\"/>
</label>
<input type=\"hidden\" id=\"action\" name=\"action\" value=\"login\" />
<input type=\"hidden\" id=\"ajaxCall\" name=\"ajaxCall\" value=\"1\" />
<input name=\"login\" type=\"submit\" id=\"login\" value=\"Login\"/><br>
".$s_remember."<input type=\"checkbox\" id=\"userRemember\" name=\"userRemember\" value=\"yes\">
</form>";
return $s_return;
}
public function doLogout(){
$getURI = $_SERVER['REQUEST_URI'];
$s_return = "<form id=\"logOut\" method=\"post\" action=\"".$getURI."\">
<input type=\"hidden\" id=\"ajaxCall\" name=\"ajaxCall\" value=\"1\" />
<input type=\"hidden\" id=\"action\" name=\"action\" value=\"logout\" />
<input name=\"logout\" type=\"submit\" id=\"logout\" value=\"Log Out\" /><br>
</form>";
return $s_return;
}
the whole thing works fine as long as you click a link after you login and reload the page, but if you login, then logout straight away it throws you to the textResponse page instead of loading into the getLog division.
any idea's on how to counteract this and load the txtResponse into the right place?
Last edited: