代码如下
UserController.class.php中
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;
ob_clean();
$Verify->entry();
}
view中
login.html代码如下:
<html>
<head>
<me
<ti
<st
#form1
{
width:300px;
height:500px;
margin:20px auto;
border:0px #039 solid;
padding:20px 20px;
}
</st
</head>
<body>
<div class="container">
<sc
function updateImg(){
var vcode=document.getElementById('vdImg');
vcode.src=
"{:U('user/verify_c',array())}?temp=Math.random()";
}
</sc
<form name="form1" id="form1" method="post" action="{:U('user/checklogin')}">
<h3> 学员登录</h3 ><br/>
<p>账 号:<input type="text" name="username" id="username" maxlength="16" /> </p><br />
<p>密 码:<input type="password" name="password" id="password" maxlength="16" /> </p><br />
<p>
验证 码:<input name="verify" width="100" height="80" placeholder="输入验证码" type="text">
</br>
<img id="vdImg" width="30%" height="40" alt="刷新验证码" src="{:U('user/verify_c',array())}" ti
<a href="ja
</p>
<p> <input type="submit" name="btn1" id="btn1" value="提交" /></p>
</br>
<p>我还不是学员需要<a href="{:U('index/hy')}">注册学员</a></p>
</form>
</div>
</body>
</html>
最佳答案
