git地址
git://github.com/kolanos/kohana-captcha.git
在 bootstrap.php 中开启
Kohana::modules(array( 'captcha'?????? => MODPATH.'captcha',?????? // 验证码模块 ………… ));
view中的写法
<form? method="post" id="Flogin">
…………
<p>
<label for="captcha">验证码:</label>
<input type="text" id="captcha" name="captcha" />
<?php? echo $captcha->render(); ?>
</p>
</form>
controller中的写法
if ($_POST) { $username = $_POST['username']; $password = $_POST['password']; if(Captcha::valid($_POST['captcha'])) { //正确的处理代码 if ( $this->auth->login($username, $password) ) { $this->request->redirect('admin'); } else { $this->template->content->message = "请输入正确的用户名密码"; } } else { //验证码错误的处理代码 $this->template->content->message = "请输入正确的验证码"; } }
原创文章,转载请注明: 转载自贝壳博客
本文链接地址: Kohana v3 captcha module 简单用法