在学习用ThinkPHP框架,做了一个注册与登陆的小东西
<?php
// 本类由系统自动生成,仅供测试用途
class UserinfoAction extends Action {
public function index(){
header("Content-Type:text/html; charset=utf-8");
$this->display("login");
}
function login(){
if(md5($_POST['verify'])!=$_SESSION['verify']){
$this->error("验证码错误");
}
//实例化自定义模型 M('User')实例化基础模型
$user=D("Userinfo");
if($user->create()){
//执行插入操作,执行成功后,返回新插入的数据库的ID
if($user->add()){
$this->success("注册成功");
}else{
$this->error("注册失败");
}
}else{
//把错误信息提示给用户看
$this->error($user->getError());
}
}
//生成图片验证码
function verify(){
//导入图形处理类库
import("ORG.Util.Image");
//import("@.ORG.Image");
//生成图形验证码
//实现英文验证码
image::buildImageVerify(4,1,'gif',60,22,'verify');
//实现中文验证码
//image::GBVerify();
}
} 对应的login.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">
<title>注册</title>
</head>
<body>
<form action='__URL__/login' method="post" >
<table width="407" height="424" align="center">
<th width="400" height="95"><H2>注册信息</H2></th>
<tr>
<td><table height="273" align="center">
<tr>
<td align="right">用 户 名:</td>
<td width="304" align="left"><input type="text" name="account_number"
onclick="checkvalue(1,this);"
onkeyup="checkvalue(1,this);"
title="用户名一经注册后不能修改,长度5——15">
<label id="tip1"></label>
</td>
</tr>
<tr>
<td align="right">昵 称:</td>
<td width="304" align="left"><input type="text" name="name" onclick="checkvalue(2,this);"
onkeyup="checkvalue(2,this);"
title="长度1——10">
<label id="tip2"></label></td>
</tr>
<tr>
<td align="right">密 码:</td>
<td width="304" align="left"><input type="password" name="password" onclick="checkvalue(3,this);"
onkeyup="checkvalue(3,this);"
title="长度8——20">
<label id="tip3"></label></td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td width="304" align="left"><input type="password" name="repassword"></td>
</tr>
<tr>
<td align="right">性 别:</td>
<td width="304" align="left"><input type="text" name="sex"></td>
</tr>
<tr>
<td align="right">生 日:</td>
<td width="304" align="left"><input type="text" name="birthday"onclick="checkvalue(6,this);"
onkeyup="checkvalue(6,this);"
title="请按照“1999-10-11”格式填写">
<label id="tip6"></label></td>
</tr>
<tr>
<td align="right">邮 箱:</td>
<td width="304" align="left"><input type="text" name="email"></td></tr>
<tr>
<td align="right">现 居 地:</td>
<td width="304" align="left"><input type="text" name="present_address"
onclick="checkvalue(8,this);"
onkeyup="checkvalue(8,this);"
title="请按照“中国-山东-烟台”的格式填写">
<label id="tip8"></label></td>
</tr> <input type="hidden" name="registration_date" value="<?php echo date('Y-m-d H:i:s',time());?>">
<tr>
<td align="right">验 证 码:</td>
<td align="left"><input type="text" name="verify" clos="18">
<img id="verify" alt="验证码" onClick="show()" src="__URL__/verify"><a href="javascript:show()">看不清楚</a></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name='sub' value="注册"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
<script>
function show(){
document.getElementById("verify").src="__URL__/verify/random"+Math.random();
} function checkvalue(n,obj){
var oTip = document.getElementById("tip"+n);
if (obj.value==""){
oTip.innerHTML =obj.title;
}else{
oTip.innerHTML ="";
}
}
</script>
昨天做的注册,今天做完登录想测试一下,结果就出问题了
点击注册之后一直提示而且我一直也没找到问题出在哪里,昨天还好好的,求求大神帮个忙
<?php
// 本类由系统自动生成,仅供测试用途
class UserinfoAction extends Action {
public function index(){
header("Content-Type:text/html; charset=utf-8");
$this->display("login");
}
function login(){
if(md5($_POST['verify'])!=$_SESSION['verify']){
$this->error("验证码错误");
}
//实例化自定义模型 M('User')实例化基础模型
$user=D("Userinfo");
if($user->create()){
//执行插入操作,执行成功后,返回新插入的数据库的ID
if($user->add()){
$this->success("注册成功");
}else{
$this->error("注册失败");
}
}else{
//把错误信息提示给用户看
$this->error($user->getError());
}
}
//生成图片验证码
function verify(){
//导入图形处理类库
import("ORG.Util.Image");
//import("@.ORG.Image");
//生成图形验证码
//实现英文验证码
image::buildImageVerify(4,1,'gif',60,22,'verify');
//实现中文验证码
//image::GBVerify();
}
} 对应的login.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">
<title>注册</title>
</head>
<body>
<form action='__URL__/login' method="post" >
<table width="407" height="424" align="center">
<th width="400" height="95"><H2>注册信息</H2></th>
<tr>
<td><table height="273" align="center">
<tr>
<td align="right">用 户 名:</td>
<td width="304" align="left"><input type="text" name="account_number"
onclick="checkvalue(1,this);"
onkeyup="checkvalue(1,this);"
title="用户名一经注册后不能修改,长度5——15">
<label id="tip1"></label>
</td>
</tr>
<tr>
<td align="right">昵 称:</td>
<td width="304" align="left"><input type="text" name="name" onclick="checkvalue(2,this);"
onkeyup="checkvalue(2,this);"
title="长度1——10">
<label id="tip2"></label></td>
</tr>
<tr>
<td align="right">密 码:</td>
<td width="304" align="left"><input type="password" name="password" onclick="checkvalue(3,this);"
onkeyup="checkvalue(3,this);"
title="长度8——20">
<label id="tip3"></label></td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td width="304" align="left"><input type="password" name="repassword"></td>
</tr>
<tr>
<td align="right">性 别:</td>
<td width="304" align="left"><input type="text" name="sex"></td>
</tr>
<tr>
<td align="right">生 日:</td>
<td width="304" align="left"><input type="text" name="birthday"onclick="checkvalue(6,this);"
onkeyup="checkvalue(6,this);"
title="请按照“1999-10-11”格式填写">
<label id="tip6"></label></td>
</tr>
<tr>
<td align="right">邮 箱:</td>
<td width="304" align="left"><input type="text" name="email"></td></tr>
<tr>
<td align="right">现 居 地:</td>
<td width="304" align="left"><input type="text" name="present_address"
onclick="checkvalue(8,this);"
onkeyup="checkvalue(8,this);"
title="请按照“中国-山东-烟台”的格式填写">
<label id="tip8"></label></td>
</tr> <input type="hidden" name="registration_date" value="<?php echo date('Y-m-d H:i:s',time());?>">
<tr>
<td align="right">验 证 码:</td>
<td align="left"><input type="text" name="verify" clos="18">
<img id="verify" alt="验证码" onClick="show()" src="__URL__/verify"><a href="javascript:show()">看不清楚</a></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name='sub' value="注册"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
<script>
function show(){
document.getElementById("verify").src="__URL__/verify/random"+Math.random();
} function checkvalue(n,obj){
var oTip = document.getElementById("tip"+n);
if (obj.value==""){
oTip.innerHTML =obj.title;
}else{
oTip.innerHTML ="";
}
}
</script>
昨天做的注册,今天做完登录想测试一下,结果就出问题了
点击注册之后一直提示而且我一直也没找到问题出在哪里,昨天还好好的,求求大神帮个忙
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货