后台:
class IndexAction extends Action {
public function index(){
$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
}
public function verify(){
import('ORG.Util.Image');
Image::buildImageVerify();
}
function yanzheng(){
$veri=$_POST['yanzhen'];
$this->display();
}
}
前台:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function fleshVerify(){
//重载验证码
document.getElementById('verifyImg').src='__URL__/verify/'+Math.random();
//var aa=document.getElementById('verifyImg');
// document.write(aa);
}
</script>
</head>
<body>
<form action="yanzheng" method="post">
<center>
<table border="1">
<tr>
<td>用户名:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>验证码:</td>
<td><input type="text" name="yanzhen" size="10"><img style='cursor:pointer' id="verifyImg" src="__URL__/verify" οnclick="fleshVerify()"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="sub" value="登陆">
<input type="reset" name="res" value="取消"></td>
</tr>
</table>
</center>
</form>
</body>
</html>