【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“15_9.php”一文,供大家参考学习
<?php
session_start();
include_once("15_2.php");
?>
<!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 />
<?php
if(isset($_GET["action"])){
switch($_GET["action"]){
case "step1":
if(isset($_POST["username"]) and $_POST["username"]!=""){
$rs = $conn->Execute("select question from members where username = '".$_POST["username"]."'");
if($rs->RecordCount()>0){
print <<<EOT
<form action="15_9.php?action=step2" method="post">
<table cellpadding="6" cellspacing="1" align="center" class="tableborder1">
<tr>
<th valign="middle" colspan="2"><b>取回密码</b>(第二步:回答问题)</th></tr>
<tr>
<td class="tablebody1" width="30%" align="left" valign="middle">取回密码
问题:{$rs->Fields("question")}</td>
<td class="tablebody1" align="left"width="70%" valign="middle">答案:<input name="answer" type="text"/>
<input name="question" type="hidden" value="{$rs->Fields("question")}"/></td>
</tr>
<tr>
<td class="tablebody2" valign="middle" colspan="2" align="center"><input type="submit" class="button" name="submit" value="提 交"/></td></tr>
</table>
</form>
EOT;
}else{
info("没有此用户.","15_9.php");
}
}else{
info("用户名不能为空.","15_9.php");
}
break;
case "step2":
$question = $_POST["question"];
$answer = $_POST["answer"];
$sql = "select id from members where question = '".$question."' and answer = '".$answer."'";
$rs = $conn->Execute($
sql);
if($rs->RecordCount()>0){
$newpass = rand(11111,99999);
$conn->Execute("update members set pass
word = '".md5($newpass)."' where question = '".$question."' and answer = '".$answer."'");
info("取回密码成功,你的新密码是{$newpass}","15_6.php");
}else{
info("回答错误,请重试.","15_9.php");
}
break;
}
}else{
print <<<EOT
<form action="15_9.php?action=step1" method="post">
<table cellpadding="6" cellspacing="1" align="center" class="tableborder1">
<tr>
<th valign="middle" colspan="2"><b>取回密码</b>(第一步:用户名)</th></tr>
<tr>
<td class="tablebody1" width="30%" align="left" valign="middle">请输入您的用户名</td>
<td class="tablebody1" align="left"width="70%" valign="middle"><input name="username" type="text"/></td>
</tr>
<tr>
<td class="tablebody2" valign="middle" colspan="2" align="center"><input type="submit" class="button" name="submit" value="提 交"/></td></tr>
</table>
</form>
EOT;
}
?>
</body>
</html>