尊龙凯时人生就是搏

thinkphpµÇ¼ºóÔõôÌøת

ÔÚÍøÕ¾µÄ¿ª·¢ÖУ¬µÇ¼ÊǺÜÊÇÖ÷ÒªµÄÒ»¸ö¹¦Ð§£¬µ±Óû§ÀֳɵǼºó£¬Ìøתµ½ºÏÊʵÄÒ³ÃæÒ²ÊÇÐëÒªµÄ£¬ÈÃÓû§¿ÉÒÔ¸üºÃµÄʹÓÃÍøÕ¾¡£ÔÚʹÓà thinkphp ¿ò¼Ü¾ÙÐпª·¢Ê±£¬ÔõÑùʵÏֵǼºóµÄÌøתÄØ£¿ÏÂÃæÎÒÃÇÀ´Ïêϸ¿´Ò»Ï¡£

Ê×ÏÈ£¬ÔڵǼÑéÖ¤Àֳɺó£¬ÎÒÃÇÐèÒª¶ÔÓû§¾ÙÐÐÉí·ÝÑéÖ¤²¢½«Óû§×´Ì¬Ð´Èë session¡£

public function login()
{
    // »ñÈ¡Óû§ÊäÈëµÄÓû§ÃûºÍÃÜÂë
    $username = $this->request->param('username');
    $password = $this->request->param('password');
    // ¶Ô»ñÈ¡µ½µÄ²ÎÊý¾ÙÐÐÅжϺʹ¦Àí
    if(empty($username) || empty($password)) {
        $this->error('Óû§ÃûºÍÃÜÂë²»¿ÉΪ¿Õ');
    }
    // ÅÌÎÊÓû§ÐÅÏ¢
    $user = Db::name('user')->where('username',$username)->find();
    if(empty($user)) {
        $this->error('Óû§Ãû²»±£´æ');
    }
    // ÑéÖ¤ÃÜÂëÊÇ·ñ׼ȷ
    if(md5($password) !== $user['password']) {
        $this->error('ÃÜÂë¹ýʧ');
    }
    // ½«Óû§µÄÐÅϢдÈë session
    session('user_id',$user['id']);
    session('user_info',$user);

    // µÇ¼Àֳɺó¾ÙÐÐÌøת
    $this->redirect('/index');
}

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉÏ´úÂëÖУ¬ÎÒÃÇÊ×ÏÈ»ñÈ¡Óû§ÊäÈëµÄÓû§ÃûºÍÃÜÂ룬ȻºóÅÌÎÊÓû§ÊÇ·ñ±£´æ£¬ÑéÖ¤ÃÜÂëÊÇ·ñ׼ȷ£¬ÈôÊǶ¼×¼È·£¬Ôò½«Óû§ÐÅϢдÈë session¡£½ÓÏÂÀ´£¬ÎÒÃǾͿÉÒÔͨ¹ý$this->redirect()¾ÙÐÐÒ³ÃæµÄÌøתÁË¡£

$this->redirect('/index');

µÇ¼ºó¸´ÖÆ

²ÎÊýÖеÄ/indexÌåÏÖÌøתµ½ÏîÄ¿µÄ¸ùĿ¼Ï嵀 index ÒªÁ죬¼´Ä¬ÈϵÄÊ×Ò³¡£ÈôÊÇÎÒÃÇÏ£ÍûÌøתµ½ÆäËûµÄÒ³Ã棬ÀýÈ繺Îï³µÒ³Ã棬ֻÐèÒªÐ޸IJÎÊý¼´¿É¡£

$this->redirect('/cart/index');

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëÌåÏÖÌøתµ½¸ùĿ¼Ï嵀 Cart ¿ØÖÆÆ÷Ï嵀 index ÒªÁìÖС£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÁíÍ⣬ÎÒÃÇÒ²¿ÉÒÔÖ±½ÓÌøתµ½Ä³Ò»¸öÏêϸµÄ URL£¬²»¹ýÐèҪעÖصÄÊÇ£¬ÐèҪʹÓÃÏà¶Ô·¾¶Ìøת¡£

$this->redirect('/html/index.html');

µÇ¼ºó¸´ÖÆ

»¹ÐèҪעÖصÄÒ»µãÊÇ£¬redirect()ÒªÁìĬÈÏÊǾÙÐÐÁË 302 Öض¨Ïò£¬ÈôÊÇÎÒÃÇÐèÒª¾ÙÐÐÓÀÊÀÐÔµÄÌøת£¬¿ÉÒÔʹÓòÎÊýÀ´Ö¸¶¨¡£

$this->redirect('/index',301);

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇÒÔ ThinkPHP ¿ò¼ÜΪÀý£¬ÊµÏֵǼºóÌøתµÄÒªÁì¡£ÔÚÏÖʵ¿ª·¢ÖУ¬ÎÒÃÇ»¹ÐèҪƾ֤×Ô¼ºµÄÐèÇóÀ´¾ÙÐÐÐ޸ĺ͵÷½â£¬ÈôÊÇÓÐÈκÎÎÊÌâ¿ÉÒÔÔÚ̸ÂÛÇøÁôÑÔ¡£

ÒÔÉϾÍÊÇthinkphpµÇ¼ºóÔõôÌøתµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ