用在二次开发时,处理验证码发送程序,适合精通php的程序员
模板代码:
<div class="form-group" id="dr_row_code"> <label class="col-md-2 control-label">图片验证</label> <div class="col-md-10"> <div class="input-group input-large"> <input class="form-control placeholder-no-fix" type="text" autocomplete="off" id="dr_code" name="code"> <div class="input-group-btn fc-code"> {dr_code(120, 35)} </div> </div> </div> </div> <div class="form-group" id="dr_row_sms"> <label class="col-md-2 control-label">短信验证</label> <div class="col-md-10"> <div class="input-group input-large"> <input class="form-control placeholder-no-fix" type="text" autocomplete="off" id="dr_sms" name="sms"> <div class="input-group-btn"> <button class="btn blue" onclick="dr_ajax_url('/index.php?s=member&c=api&m=send_code&&code='+$('#dr_code').val()+'id='+$('#dr_phone').val())" type="button">获取手机验证码</button> </div> </div> </div> </div>
id传递手机号码
程序判断部分:
$code = \Phpcmf\Service::L('cache')->init()->get('member-send-phone-'.$phone); if (!$code) { $this->_json(0, dr_lang('没有发送验证码')); } elseif ($code != $_POST['sms']) { $this->_json(0, dr_lang('验证码不正确')); }