圖形驗證碼的制作看似困難,實則非常簡單,因為cmf為我們提供了驗證碼的標簽,都封裝好了。
cmf官方文檔中給我們寫的十分詳細了
[驗證碼官方文檔](http://www.hmoore.net/thinkcmf/doc/266558)
前端調用
\plugins\guestbook\view\widget.html
~~~
<div class="contact-form">
<form id="guestbook-form" class="no-mar" role="form">
<div class="form-group sy-guestbook">
<label for="name">姓名<span class="require-item">*</span></label>
<input type="text" class="form-control" id="name" name="name" placeholder="">
<i class="fa fa-user form-control-guestbook"></i>
</div>
//這里是新增驗證碼代碼---start
<div class="form-group sy-guestbook">
<label for="message">驗證<span class="require-item">*</span></label>
<div class="sy-guestbook">
<input type="text" name="captcha" placeholder="驗證碼" class="form-control captcha"
style="width: 170px;float: left;margin-right: 30px">
<captcha height="38" width="160" font-size="20"/>
</div>
</div>
<div class="g-recaptcha"></div>
//這里是新增驗證碼代碼---end
<input id="guestbook-submit" value="提交" class="submit-button btn btn-default">
</form>
</div>
~~~
后端驗證
IndexController.php
~~~
/**
* 提交留言
*/
public function addMsg()
{
*~~~*
// 驗證碼校驗
if (!cmf_captcha_check($data['captcha'])) {
$this->error("驗證碼錯誤");
}
*~~~*
}
~~~

> 首先感謝WelkinVan 他寫的《ThinkCMF5從入門到精通》給了我很多幫助
> 點擊去《[ThinkCMF5從入門到精通](http://www.hmoore.net/welkinvan/thinkcmf5)》
>
- php套路
- 套路之類結構
- thinkphp分塊解析之Collection
- thinkphp基礎之collection
- Collection在thinkphp中的運用
- thinkcmf模塊分析
- Controller按界面點擊順序排列表
- user模塊-Controller分析
- portal模塊-Controller分析
- admin模塊-Controller分析
- user模塊-腦圖
- portal模塊-腦圖
- admin模塊-腦圖
- cmf公共函數解析-common.php
- thinkcmf點滴記錄
- 自定義標簽詳解
- 插件
- 系統信息插件
- 插件演示插件
- 留言板插件
- 留言板1 建立胚胎
- 留言板1-1 數據庫變化
- 留言板1-2 自定義鉤子
- 留言板2 連接數據庫
- 留言板3 讀取后臺界面數據
- 留言板4 前端模板
- 留言板5 分離cssjs文件
- 留言板6 驗證
- 留言板7 圖形驗證碼
- 留言板8 后臺留言列表頁
- 留言板9 后記
- 評論插件
- 1 分析數據表
- 2 CommentModel.php
- 3 UserModel.php
- 4 DCommentPlugin.php
- 前端調用代碼
- 喜歡插件
- 1 分析
- 2 收藏功能
- 3 插件建模
- 4 數據庫設計
- 5 插入一條數據
- 多語言
- thinkphp多語言
- thinkcmf多語言