Mysql和PHP结果可以,但登录不正确


Mysql and PHP Result is okay but login incorrect

我有mysql连接及其工作。连接完成,mysql结果正常。我试图登录我的面板,但每次都给出"密码不正确"/Kullanıcıadınız veyaşifreniz yanlış。我该怎么解决这个问题?

if(@$_GET['selection'] == 'verification' ) 
    {
        $myusername=$_POST['myusername'];
        $mypassword=$_POST['mypassword'];
        $tbl_name="kullanicilar";
        $myusername = stripslashes($myusername);
        $mypassword = stripslashes($mypassword);
        $myusername = mysql_real_escape_string($myusername);
        $mypassword = mysql_real_escape_string($mypassword);
        $sql="SELECT * FROM kullanicilar WHERE kullaniciadi='$myusername' and sifre='$mypassword'";
        $result=@mysql_query($sql);
        $count=@mysql_num_rows($result);
        if (@mysql_num_rows($result) != 0)
        {
            session_register("myusername");
            session_register("mypassword");
            header("location:index.php?page=giris&lang=tr&selection=verified");
        }
        else 
        {
            echo "Kullanici adiniz veya sifreniz yanlis. <b>$count</b>";
        }
    }

您需要做一些事情:

  1. 在"if"条件中使用$count,而不是再次调用mysql_num_rows函数。每个mysql函数调用都是您想要避免的开销。

  2. 请尝试通过注释"stripeshases"行来编写代码。

  3. 回显并获取查询。然后在没有这个脚本的情况下直接运行查询(比如在SQLYog或phpMyAdmin中),看看它是否会给你结果。