我在COdeigniter
编程中使用 PHP 登录脚本。如果我在此表单中输入正确的凭据,它会显示一个error
,而在输入正确的凭据后,如果我在新选项卡中打开相同的表单,它会自动打开。似乎,一些js问题。任何的想法 ?这里是code
<form method="post" action="#" onsubmit="return validateLogin('loginForm')" name="loginForm">
<table width="100%" cellpadding=0 cellspacing=0>
<tr>
<td>
<b>
Username:
</b>
</td>
<td>
<input type="text" name="usr" />
</td>
</tr>
<tr>
<td>
<b>
Password:
</b>
</td>
<td>
<input type="password" name="pwd" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Login" class="submit" />
</td>
</tr>
</table>
</form>
功能是
function validateLogin(form) {
user = document.forms[form].usr;
pwd = document.forms[form].pwd;
if(user.value.length==0)
{
notify('Please enter a valid username', 'error');
user.focus();
hilit('[name = user]');
return false;
}
else if(pwd.value.length==0)
{
notify('Please enter a valid password', 'error');
pwd.focus();
hilit('[name = pwd]');
return false;
}
else
{
notify('processing.... please wait', 'notice');
dataString = 'user='+user.value+'&pwd='+pwd.value;
jQuery.ajax({
type: "POST",
data: dataString,
url: baseurl+'admin/checkLogin',
cache: false,
error: function()
{
notify("An error occurd... please try later", 'error');
},
success: function(html)
{
if(html == 1)
{
window.location = baseurl+'admin/home';
}
else
{
notify('Your login details are incorrect!!!', 'error');
}
}
});
return false;
}
return false;
}