視圖層
<div class="loginbox-textbox"> <input class="form-control" placeholder="請輸入驗證碼" name="captcha" type="text"/> <img id="cap" alt="驗證碼" title="點擊刷新" style="width:220px;cursor: pointer; margin: 20px 0;border:2px solid rgb(220, 222, 224);" onclick="this.src='{:captcha_src()}'" src="{:captcha_src()}"/> </div>
控制器驗證
//接收數據 $captcha = input("post"); if(!captcha_check($captcha['captcha'])){ //輸入的驗證碼錯誤 }else{ //輸入的驗證碼正確 }