分享一個用戶名,手機號,會員卡號都能登陸的代碼
如今越多越多的網站會員都流行手機號碼登陸,由於這樣最方便,那
星辰博客
就告訴你們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');
}
歡迎關注本站公眾號,獲取更多信息