Arkham's Razor: The simplest explanation is the best.
after doing all that stuff I found that the whole thing didn't work with session variables(server side)
so I had to rethink again and went back to my original code...
here are the changes i made to my original code...
Code:
$(document).ready(function()
{
$('#loginf').ajaxForm({
beforeSubmit: function () { $('#getLog').html('<img src="/img/ajax-loader.gif">');},
target: '#getLog',
success: function () {
var response = showResponse;
if (response != undefined){
$('#getLog').html(showResponse).fadeIn("slow");
}
}
});
});
php changes:
PHP Code:
$s_doLogin = $this->loginDisp();
if (isset($_POST['ajaxCall']) && $_POST['ajaxCall'] == '1'){
echo $s_doLogin;
die;
}
public function loginDisp(){
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;
}
and the forms (this is the important part)
PHP Code:
public function doLogin($s_user, $s_pass, $s_remember="Remember"){
$getURI = $_SERVER['REQUEST_URI'];
$s_return = "<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\">
";
return $s_return;
}
public function doLogout(){
$getURI = $_SERVER['REQUEST_URI'];
$s_return = "<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>
";
return $s_return;
}
You will notice I removed the form line!!!
HTML now looks like this.....
Code:
<table width="140" align="left" border="0" cellspacing="0" cellpadding="0" id="sidebar1">
<tr>
<td align="center" height="150">
<form id="loginf" method="post" action="index.php">
<div id="getLog">{LOGIN}</div></form>
</td>
</tr>
<tr>
<td align="center" valign="top">{SIDEBAR}</td>
</tr>
</table>
I placed the form tag OUTSIDE of the "getLog" division....
Now all works perfect and less effort then the original re-write...:facesjump