Home  >  Article  >  Backend Development  >  php对应查寻,求指导

php对应查寻,求指导

WBOY
WBOYOriginal
2016-06-13 11:52:341064browse

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"点击此处登入";
   
}

?>

------解决方案--------------------

$sql = "select <span style="color: #FF0000;">*</span>from user where username='".$username."' and answer='".$answer."' ";


*后面少了一个空格
------解决方案--------------------
你只是
$result=mysql_query($sql); //执行查询
$num=mysql_num_rows($result); //读取结果集记录数
if($num>0) //判断已查到
{  
   echo "你的密码是['password']";

并没有读取查询到的结果

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn