我登录并选择不记住它发生此错误
注意:未定义索引:isRemember in 第16行的web / controllers / cont.userForm.php
代码cont.userForm.php
if(isset($_POST) && $_GET['action'] == 'login' && $_GET['token'] == $_SESSION['token']){
if($huy->isExist(APP_TABLES_PREFIX . 'user','id',array('email'=>$_POST['email'],'password'=>sha1($_POST['password'])))){
$thisUser = $db->Query(APP_TABLES_PREFIX . 'user','role',array('email'=>$_POST['email'],'password'=>sha1($_POST['password'])));
if($thisUser['0']['role'] == 0){
$user->alert('danger',$l['email_not_confirmed']);
}else{
if ($_POST['isRemember'] == 0){
$user = $db->Query(APP_TABLES_PREFIX . 'user','*',array('email'=>$_POST['email'],'password'=>sha1($_POST['password'])));
$db->Update(APP_TABLES_PREFIX . 'user',array('email'=>$_POST['email']),array('last_login'=>$now));
$_SESSION['userId'] = $user['0']['id'];
echo '...';
}else{
$user = $db->Query(APP_TABLES_PREFIX . 'user','*',array('email'=>$_POST['email'],'password'=>sha1($_POST['password'])));
$db->Update(APP_TABLES_PREFIX . 'user',array('email'=>$_POST['email']),array('last_login'=>$now));
$_SESSION['userId'] = $user['0']['id'];
setcookie("userId", $user['0']['id'], time() + (10 * 365 * 24 * 60 * 60), '/', NULL, 0 );
setcookie("hash", md5($user['0']['id'].$user['0']['password']), time() + (10 * 365 * 24 * 60 * 60), '/', NULL, 0 );
echo '...';
}
}
}else{
$user-> alert('danger',$l['login_incorrect']);
}
}
答案 0 :(得分:1)
您可以更改if语句以检查POST变量是否存在:
if (isset($_POST['isRemember'] && $_POST['isRemember'] == 1){
...
}
else
{
...
}
如果未选中复选框,则不会发送复选框,因此会出现未定义的索引错误。