这是我的代码我无法让 if 语句工作,如果名称不存在,它会显示“找到记录”并且 page3.php 说密码不匹配可以有人帮我解决这个问题吗 谢谢
<?php
session_start();
//$_SESSION["authorized"]=0;
$name = $_POST["name"];
$pass = ($_POST["password"]);
$connect = mysql_connect("localhost","tina","tinapassword") or die("Could not connect");
$selected = mysql_select_db("tinadatabase", $connect) or die("Could not connect to database");
$query = "SELECT * FROM users WHERE Uname='$name'";
$result = mysql_query($query, $connect);
$row = mysql_fetch_assoc($result);
if ($result)
{
//$row ==1;
print "Record found";
}
else
{
//$row == 0;
print "Record not found";
}
print "<br>";
md5($pass);
if($name == $result["Uname"] && md5('$pass') == $result["Upassword"])
{
$_SESSION["authorized"] = 1;
}
else
{
$_SESSION["authorized"] = 0;
}
print "<br>";
print"<a href='page3.php'> continue</a>";
?>