尊龙凯时人生就是搏

ThinkPHP×Ô¶¯ÑéÖ¤µÄÐ޸Ĺ¦Ð§ÔõôÓÃ

Ò»¡¢ThinkPHP×Ô¶¯ÑéÖ¤¼ò½é

ThinkPHP×Ô¶¯ÑéÖ¤ÊÇ¿ò¼ÜÄÚÖõÄÒ»Ì×ÑéÖ¤»úÖÆ£¬Ëü¿ÉÒÔÔÚÄ£×ÓÖÐͨ¹ýÉèÖÃÑéÖ¤¹æÔòºÍ¹ýʧÌáÐÑÐÅÏ¢£¬²¢ÍŽá¿ØÖÆÆ÷ÖеÄÏÖʵ³¡¾°¾ÙÐÐÊý¾ÝÑéÖ¤¡£Ê¹ÓÃ×Ô¶¯ÑéÖ¤¿ÉÒÔ×èÖ¹·±ËöµÄÊÖ¶¯ÑéÖ¤Àú³Ì£¬Ìá¸ß¿ª·¢Ð§ÂÊ¡£Í¨¹ý×Ô¶¯ÑéÖ¤£¬¿ÉÒÔïÔÌ­¹ýʧ´¦Àí´úÂ룬ÓÉÓÚµ±Êý¾Ý²»·¨Ê±£¬Ëü»áÖ±½Ó·µ»Ø¹ýʧÐÅÏ¢¡£

ThinkPHP×Ô¶¯ÑéÖ¤µÄ»ù±¾Ê¹ÓÃÒªÁìÈçÏ£º

ÔÚÄ£×ÓÖнç˵ÑéÖ¤¹æÔòºÍ¹ýʧÌáÐÑÐÅÏ¢£º

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

protected $_validate = array(
    // ÑéÖ¤Óû§ÃûÊÇ·ñÕýµ±
    array('username','require','Óû§Ãû²»¿ÉΪ¿Õ£¡'),
    array('username','','¸ÃÓû§ÃûÒѱ»×¢²á',0,'unique'),
    array('username','/^[\w\-\x{4e00}-\x{9fa5}]{2,16}$/','Óû§Ãû²»Õýµ±£¡',0,'regex'),
    // ÑéÖ¤ÓÊÏäÊÇ·ñÕýµ±
    array('email','require','µç×ÓÓÊÏä²»¿ÉΪ¿Õ£¡'),
    array('email','','¸ÃÓÊÏäÒѱ»×¢²á',0,'unique'),
    array('email','email','µç×ÓÓÊÏäÃûÌò»×¼È·£¡',0,'regex'),
    // ÑéÖ¤ÃÜÂëÊÇ·ñÕýµ±
    array('password','require','ÃÜÂë²»¿ÉΪ¿Õ£¡'),
    array('password','/^[\S]{6,32}$/','ÃÜÂëÃûÌò»×¼È·£¡',0,'regex'),
);

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷ÖоÙÐÐÊý¾ÝÑéÖ¤£º

public function register(){
    if(IS_POST){
        $user = D('User');
        if(!$user->create()){
            $this->ajaxReturn(array('status'=>0,'msg'=>$user->getError()));
        }else{
            $user->add();
            $this->ajaxReturn(array('status'=>1,'msg'=>'×¢²áÀֳɣ¡'));
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇʹÓÃ$user->create()¾ÙÐÐÊý¾ÝÑéÖ¤£¬ÈôÊÇÑé֤ʧ°Ü£¬ÔòʹÓÃ$user->getError()»ñÈ¡¹ýʧÐÅÏ¢£¬²¢·µ»Ø¸øÇ°¶ËÒ³Ãæ¡£ÈôÊÇÑéÖ¤Àֳɣ¬Ôò½«Êý¾ÝÌí¼Óµ½Êý¾Ý¿âÖС£

¶þ¡¢ThinkPHP×Ô¶¯ÑéÖ¤ÐÞ¸Ä

ÔÚÏÖʵ¿ª·¢Àú³ÌÖУ¬ÓÐʱ¼äÐèÒª¶ÔijЩ×ֶξÙÐиüУ¬¿ÉÊÇÔÚÕâÖÖÇéÐÎÏÂÒ²ÐèÒª¾ÙÐÐÊý¾ÝÑéÖ¤¡£ËäÈ»ÎÒÃÇ¿ÉÒÔʹÓÃ×Ô¶¯ÑéÖ¤»úÖÆ£¬¿ÉÊǸûúÖÆ»áÔÙ´ÎÑéÖ¤ËùÓеÄÑéÖ¤¹æÔò£¬µ¼ÖÂʱ¼äºÍ×ÊÔ´µÄÆÌÕÅ¡£

ΪÏàʶ¾öÕâ¸öÎÊÌ⣬ThinkPHPÌṩÁË×Ô¶¯ÑéÖ¤µÄÐ޸Ĺ¦Ð§£¬Ëü¿ÉÒÔƾ֤Ŀ½ñ³¡¾°£¬Ö»¶ÔÐèÒªÑéÖ¤µÄ×ֶξÙÐÐÑéÖ¤¡£ÈôÊÇÄúÒªÐÞ¸ÄÊý¾Ý¿âÖеÄusernameºÍemail×ֶΣ¬¶ø²¢²»ÐèÒª¶Ôpassword¾ÙÐÐÑéÖ¤£¬Ôò¿ÉÒÔʹÓÃÈçÏ´úÂ룺

public function update(){
    if(IS_POST){
        $user = D('User');
        $data = array(
            'id' => $_POST['id'],
            'username' => $_POST['username'],
            'email' => $_POST['email'],
        );
        if(!$user->create($data, 2)){
            $this->ajaxReturn(array('status'=>0,'msg'=>$user->getError()));
        }else{
            $user->save();
            $this->ajaxReturn(array('status'=>1,'msg'=>'¸üÐÂÀֳɣ¡'));
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇת´ïÁ˵ڶþ¸ö²ÎÊý2£¬ÌåÏÖÄ¿½ñΪ¸üг¡¾°¡£ÕâÑù£¬ÔÚcreate()ÒªÁìÖУ¬¿ò¼ÜÖ»»á¶ÔusernameºÍemail¾ÙÐÐÑéÖ¤£¬¶ø²»»á¶ÔÆäËû×ֶξÙÐÐÑéÖ¤¡£

ÒÔÉϾÍÊÇThinkPHP×Ô¶¯ÑéÖ¤µÄÐ޸Ĺ¦Ð§ÔõôÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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