现在越多越多的网站会员都流行手机号码登录,因为这样最方便,那 星辰博客
就告诉大家ecshop的会员如何用手机号码登录;
/**手机号
登录
**/
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');
}