Thinkphp 3.2 添加 驗證碼 如何添加。

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   ar   color   sp   java   

1,在home模組indexController.class.php中,加入以下代碼

<?phpnamespace Home\Controller;use Think\Controller;class BookController extends Controller {    public function verify_c(){        $Verify = new \Think\Verify();        $Verify->fontSize = 18;        $Verify->length   = 4;        $Verify->useNoise = false;        $Verify->codeSet = ‘0123456789‘;        $Verify->imageW = 130;        $Verify->imageH = 50;        //$Verify->expire = 600;        $Verify->entry();    }         public function img(){       $this->display();    }}

 

2. 在img 視圖中,加入以下代碼

<script type="text/javascript" src="__PUBLIC__/js/jquery2.0.3.min.js"></script><p class="top15 captcha" id="captcha-container">    <input name="verify" width="50%" height="50" class="captcha-text" placeholder="驗證碼" type="text">    <img width="100" class="left15" height="50" alt="驗證碼" src="{:U(‘Home/Book/verify_c‘,array())}" title="點擊重新整理"></p>        <script type="text/javascript">            $(function(){                var captcha_img = $(#captcha-container).find(img);                var verifyimg = captcha_img.attr("src");                captcha_img.attr(title, 點擊重新整理);                captcha_img.click(function(){                    if( verifyimg.indexOf(?)>0){                        $(this).attr("src", verifyimg+&random=+Math.random());                    }else{                        $(this).attr("src", verifyimg.replace(/\?.*$/,‘‘)+?+Math.random());                    }                });            })        </script>

這樣就可以了,就能顯示出 驗證碼了。

參考學習 網址:http://blog.csdn.net/yafei450225664/article/details/40424025

Thinkphp 3.2 添加 驗證碼 如何添加。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.