ThinkPHP之用户注册登录留言完整实例(2)
UserModel.class.php页面: phpclass UserModel extends Model{protected $_validate = array(array('username','','帐号名称已经存在!',0,'unique',1), ); } 这里需要注意的是,使用自动验
UserModel.class.php页面:
<?php
class UserModel extends Model{
protected $_validate = array(
array('username','','帐号名称已经存在!',0,'unique',1),
);
}
?>
这里需要注意的是,使用自动验证的时候 实例化时要用 $user = D("user") 而不能用 $user = M("user"),用M这种方法会报错,D函数用于实例化Model,M函数用户实例化一个没有模型的文件。
success.html页面:
<!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">
<meta http-equiv="refresh" content="20; url='{$jumpUrl}'" />
<title>信息提示</title>
</head>
<body>
<div id="man_zone">
<table width="40%" border="1" align="center" cellpadding="3" cellspacing="0" class="table" style="margin-top:100px;">
<tr>
<th align="center" style="background:#cef">信息提示</th>
</tr>
<tr>
<td><p>{$message}<br />
2秒后返回指定页面!<br />
如果浏览器无法跳转,<a href="{$jumpUrl}" rel="external nofollow" >请点击此处</a>。</p></td>
</tr>
</table>
</div>
</body>
</html>
精彩图集
精彩文章






