html代码
<form action="__URL__/log" method="post">
<table><tbody>
<tr>
<td></td>
<td style="height:50px;"><img src="__PUBLIC__/images/hydl.gif" /></td>
</tr>
<tr>
<td style="text-align:right;">用户名:</td>
<td><input type="text" name="user_name"/></td>
</tr>
<tr>
<td style="text-align:right;">密码:</td>
<td><input type="password" name="user_pass"/> <a href="">忘记密码?</a></td>
</tr>
<tr>
<td>验证码:</td>
<td style="width:300px;"><div><input id="Text4" name="logx" type="text" class="lgin" style="width:100px;" />
<img id="log" name="log" title="点击刷新验证码" onclick="ref()" src="__URL__/regh"></div>
</td>
</tr>
<tr>
<td style="text-align:right;"></td>
<td><input id="Checkbox2" type="checkbox" style="width:20px;vertical-align:middle;"/>记住用户名和密码</td>
</tr>
<tr>
<td style="text-align:right;"></td>
<td><input type="submit" value="" style="background:url('__PUBLIC__/images/dlbtn.gif');width:76px;height:29px;border:0px;margin-left:35px;" /></td>
</tr>
<tr>
<td style="text-align:right;"></td>
<td>没有账号?<a href="__URL__/userReg">注册一个</a></td>
</tr>
</tbody>
</table>
</form>
<!--实现验证码刷新-->
<script>
function ref(){
document.getElementById('log').src="__URL__/regh/random/"+Math.random();
}
</script>
后台代码:
//表单提交到的地方
function log(){
header('Content-type:text/html;charset=utf-8');
//$this->uadd('Users');
//echo $_POST['regx'];
if (md5($_POST['logx']) != $_SESSION['verify']) {
echo '<script>alert("验证码错误");window.location.href="'.__URL__.'/userLogin"</script>';
}
else {
$users=D();
//密码没有加密
$se_user=$users->query("select users_id from users where users_name='".$_POST['user_name']."' and users_pass='".md5($_POST['user_pass'])."'");
if(count($se_user)) {
header("location:".__URL__."/index");
$_SESSION['user_name']=$_POST['user_name'];
$_SESSION['user_id']=$se_user[0]['users_id'];
}else{echo '<script>alert("姓名或密码错误!!!");window.location.href="'.__URL__.'/userLogin"</script>';
}
}
}
//引用自己封装好的函数
function regh(){
//自己封装的方法
$this->proving();
}
413

被折叠的 条评论
为什么被折叠?



