求助!手机登陆 mobile 页面 出现 Warning

2016-07-07 15:16 来源:www.chinab4c.com 作者:ecshop专家

打开首页出现下面情况:

坐等高手回复、指点迷津。。。
感激不尽。。。

回答:
可能你修改了的程序 在使用foreach 的时候没有判断被循环的数组是否为空导致了错误

/**手机号登录**/
if($login_type ==1)
{
$mobile = $username;
if(!preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$mobile))
{
show_message('手机号格式错误', '请重新登录', 'user.php', 'error');

}
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'" );
if($num ==1)
{
$row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'");

if ($row)
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name']= $row['username'];
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}

}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' " );
if($num==0)
{
show_message('此手机号还未注册,您可以用此手机号新注册一个会员帐号,如果您已有有本站会员帐号,请登录后绑定手机号后方可使用手机登录!', array('立即注册此手机号','重新登录'), array('user.php?act=register&mobile='.$mobile,'user.php'), 'error');

}
show_message('手机号登录失败', '请重新登录', 'user.php', 'error');

}


}
/**会员卡登录**/
if($login_type ==2)
{
$card_user_id = $db->getOne("select user_id from " . $ecs->table('user_card') ." where card_no='$username' and card_pass='$password' and is_show =1 " );
if($card_user_id)
{
$user_name = $db->getOne("select user_name from " . $ecs->table('users') ." where user_id='$card_user_id'" );

if ($user_name)
{
$_SESSION['user_id'] = $card_user_id;
$_SESSION['user_name']= $username;
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}

}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('user_card') ." where card_no='$username' and card_pass ='$password'and user_id=0 and is_show=1 " );
if($num==1)
{
show_message('此卡号还未绑定,您可以用此新注册一个会员帐号并绑定此卡号,如果您已有本站会员帐号,请登录后在会员中心绑定此卡号后方可登录!', array('立即注册并绑定此卡号','重新登录'), array('user.php?act=register&card_no='.$username.'&card_pass='.$password,'user.php'), 'error');

}

show_message('会员卡登录失败', '请重新登录', 'user.php', 'error');

}


}
if ($user->login($username, $password))
{
update_user_info();
recalculate_price();
$ucdata = isset($user->ucdata)? $user->ucdata : '';
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}