php对应查找,求指导
想通过用户名和问题找回密码,这样写错在哪?
(已知数据库里用户名不重复)
<?php
$username = $_POST['username'];
$fquestion = $_POST['fquestion'];
$answer= $_POST['answer'];
include('conn.php');
mysql_query("set character set 'gbk'");
mysql_query("set names 'gbk'");
$sql = "select *from user where username='".$username."' and answer='".$answer."' ";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
echo "你的密码是['password']";
echo"点击此处<a href='denglu.html'>登入</a>";
}
?>
------解决方案--------------------$sql = "select *from user where username='".$username."' and answer='".$answer."' ";
*后面少了一个空格
------解决方案--------------------你只是
$result=mysql_query($sql); //执行查询
$num=mysql_num_rows($result); //读取结果集记录数
if($num>0) //判断已查到
{
echo "你的密码是['password']";
并没有读取查询到的结果