0
我有mysql連接及其工作。連接完成,MySQL結果可以。我試圖登錄我的面板,但每次給「密碼不正確」/Kullanıcıadınızveyaşifrenizyanlış。我怎樣才能解決這個問題?Mysql和PHP結果很好,但登錄不正確
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'";
[email protected]_query($sql);
[email protected]_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>";
}
}
請不要在新代碼中使用'mysql_ *'函數。他們不再被維護,社區已經開始[棄用流程](http://news.php.net/php.internals/53799)。看到[**紅框**](http://php.net/mysql-connect)?相反,您應該瞭解[準備好的陳述](http://en.wikipedia.org/wiki/Prepared_statement)並使用[PDO](http://php.net/pdo)或[MySQLi](http:// php.net/mysqli)。如果你不能決定,試試[這篇文章](http://php.net/mysqlinfo.api.choosing)。如果你關心學習,[這裏是很好的PDO教程](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers)。 –
你是否以明文存儲你的密碼?爲我們提供數據庫結構和html表單結構 – rsz
刪除@並查看是否生成錯誤,可能會給你更多的信息。你可能也想在沒有WHERE子句的情況下從表中進行選擇,並遍歷比較結果,一路輸出結果......可能你只是不匹配字符串。 – Dave