📄 modifyquestion.php
字号:
<? ob_start(); ?>
<script>
function changebg(obj,color){
obj.style.backgroundColor=color
}
function showExtraText(obj){
if(obj.value == "myQuestion"){
var td = tableQuestion.insertRow(1);
//添加两列
var tr1 = td.insertCell();
var tr2 = td.insertCell();
//设置列内容和属性
//tr1.innerHTML = '<span class=dax>自定义问题:</span>';
tr2.innerHTML= '<input type=text name=myQuestion size=26>';
}else
if(tableQuestion.rows(1).cells(1).innerText == ""){
tableQuestion.deleteRow(1);
}
}
</script>
<body background="../danse3.jpg">
<form action="modifyQuestion.php" method="post">
<center>
<!--提示信息 begin-->
<center><strong>修改密码提示问题和答案<strong></center><br><br><br>
<hr>
<!--提示信息 end-->
<!--内容 begin-->
<table width=540 border=2 cellpadding=0 cellspacing=1 bgcolor="#0099FF">
<tr><td bgcolor="#7dafdb">
<br><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="right">密码提示问题:</td>
<td align="left"><? include realpath('../Sysconf.php');
$username=$_COOKIE["username"];
$sql="select * from user_base_information where user_name = '$username' ;";
$result=mysql_query($sql);
$question=mysql_result($result,0,'question');
echo $question;
?>
</td></tr>
</table><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align=right ><font color=red>*</font>请输入原答案:</td>
<td align=left width="310"><input type="text" name="primaryAnswer" size="22" ><div id=loginname style="DISPLAY:none"></div></td></tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="tableQuestion">
<tr><td align=right ><font color=red>*</font>请选择密码提示问题:</td>
<td align=left width="310">
<select id="question" name="question" class="text" title="密码保护问题" onFocus="changebg(this,'pink')" onBlur="changebg(this,'white')" onChange="showExtraText(this)" style="width:197px">
<option value="" selected="selected">请选择一个问题</option>
<option value="我就读的第一所学校的名称?" >我就读的第一所学校的名称?</option>
<option value="我最喜欢的休闲运动是什么?" >我最喜欢的休闲运动是什么?</option>
<option value="我最喜欢的运动员是谁?" >我最喜欢的运动员是谁?</option>
<option value="我最喜欢的物品的名称?" >我最喜欢的物品的名称?</option>
<option value="我最喜欢的歌曲?" >我最喜欢的歌曲?</option>
<option value="我最喜欢的食物?" >我最喜欢的食物?</option>
<option value="我最爱的人的名字?" >我最爱的人的名字?</option>
<option value="我最爱的电影?" >我最爱的电影?</option>
<option value="我妈妈的生日?" >我妈妈的生日?</option>
<option value="我的初恋日期?" >我的初恋日期?</option>
<option value="myQuestion" >我的自定义问题</option>
</select>
</td></tr>
</table><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align=right ><font color=red>*</font>请输入答案:</td>
<td align=left width="310"><input type="text" name="answer" size="22" ><div id=loginname style="DISPLAY:none"></div></td></tr>
</table><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td></td><td></td></tr>
<tr><td width="100%" colspan=2 align=center><input type=submit name=submit value="提交修改"></td></tr>
</table><br><br>
</td>
</tr>
</table>
</center>
</form>
</body>
<?
//include realpath('../Sysconf.php');//连接数据库
function showWrongMes($mes){
echo "<script>alert('$mes')</script>";
echo "<script>window.location.href='modifyQuestion.php'</script>";
}
function showRightMes($mes){
echo "<script>alert('$mes.')</script>";
echo "<script>window.location.href='../safeCenter.php'</script>";
}
if($_POST["submit"]=="提交修改"){
$pa=$_POST["primaryAnswer"];
$select=$_POST["question"];
$answer=$_POST["answer"];
if($pa == "")
showWrongMes("原来的答案不能为空!");
elseif($select =="")
showWrongMes("请选择一个问题!");
elseif($answer=="")
showWrongMes("请填写问题的答案!");
else{
if($select=="myQustion"){
$myQuestion=$_POST["myQuestion"];
if($myQuestion=="")
showWrongMes("请填写自定义问题!");
}
$username=$_COOKIE["username"];
$sql="select *
from user_base_information
where user_name = '$username' and answer='$pa';";
$result=mysql_query($sql);
if(mysql_fetch_row($result)==true){
$question=($select!="myQuestion"?$select:$myQuestion);
$sql="update user_base_information
set question='$question'
where user_name='$username'";
$resultA=mysql_query($sql) or die("数据库更新失败!");
$sql="update user_base_information
set answer='$answer'
where user_name='$username'";
$resultB=mysql_query($sql) or die("数据库更新失败!");
if($resultA==true && $resultB ==true)
showRightMes("密码提示问题和答案修改成功!");
}else
showWrongMes("答案错误!");
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -