【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“15_6.php”一文,供大家参考学习!
<?php
session_start();
include_once("15_2.php");
if(isset($_GET["action"]) and $_GET["action"]=="login"){
$username = $_POST["username"];
$password = $_POST["password"];
$times = $_POST["cookiedate"];
$code = $_POST["getcode"];
//取得SESSION记录的单个验证码,并转换成字符串
$scode = "";
for($i=0;$i<4;$i++){
$scode .= iconv("utf-8","gb2312",$_SESSION["chars"][$i]);
}
if($code != $scode){
echo "<script>
alert('您输入的验证码错误,请重试。');
window.location.href='15_6.php';
</script>";
}
$rs = $conn->Execute("select id from members where username = '{$username}' and password = '".md5($password)."'");
if($rs->RecordCount()>0){
setcookie("username",$username,time()+$times);
setcookie("pass
word",md5($password),time()+$times);
echo "<script>
alert('登录成功。');
window.location.href='15_7.php';
</script>";
}else{
echo "<script>
alert('用户名或密码错误。');
window.location.href='15_6.php';
</script>";
}
}else{
print <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD X
HTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="zh-CN" lang="zh-CN"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>用户登录</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
<table cellpadding="5" cellspacing="0" align="center" class="tableborder1" style="border-top:none;">
<form action="15_6.php?action=login" method="post">
<tr>
<th colspan="2" align=left>请输入您的用户名和密码</th>
</tr>
<tr align=left>
<td class="tablebody6" width="25%"><B>用户名</B></td>
<td class="tablebody5"><input name="username" type="text" tabindex="1"/> <a href="15_3.php">没有
注册?</a></td></tr>
<tr align=left>
<td class="tablebody6"><B>密码</B></td>
<td class="tablebody5"><input name="password" type="password" tabindex="2"/> <a href="15_9.php">忘记密码?</a></td></tr>
<TR align=left>
<TD class=tablebody6><b>验证码</b>:</TD>
<TD class=tablebody5>
<script language="javascript">
function showCode(){
var code = document.getElementById('showcode');
if(code.style.display=="none"){
code.style.display = "";
}
}
</script>
<input name="getcode" type="text" size=8 tabindex="3" onfocus="showCode()"/>
<span id='showcode' style='display:none;'><img src='15_1.php' width=200 height=100 /></span>
</TD>
</TR>
<tr align=left>
<td class="tablebody6" valign="top" width="25%" ><b>Cookie 有效期</b></td>
<td valign="middle" class="tablebody5" > <input type="radio" name="cookiedate" value="0" class="radio" /> 即时
<input type="radio" name="cookiedate" value="3600" class="radio" /> 一小时
<input type="radio" name="cookiedate" value="86400" class="radio" /> 一天
<input type="radio" name="cookiedate" value="2592000" class="radio" checked="checked"/> 一月
<input type="radio" name="cookiedate" value="31536000" class="radio"/> 一年
</td></tr>
<tr>
<td class="tablebody5" valign="middle" colspan="2" align="center"><input type="submit" name="submit" value="登录" class="button"/></td></tr></form></table>
</body>
</html>
EOT;
}
?>