这是我的代码我不能得到的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>";
?>
欢迎来到程序员。请阅读[about](http://programmers.stackexchange.com/about)页面。这个问题属于StackOverflow。我会标记它被迁移。 –
抱歉不知道如何使用此页我欣赏帮助 –
您正在使用[an **过时的**数据库API](http://stackoverflow.com/q/12859942/19068)并且应该使用[modern更换](http://php.net/manual/en/mysqlinfo.api.choosing.php)。你也**易受[SQL注入攻击](http://bobby-tables.com/)**,现代的API会使[防御]更容易(http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php)自己从。 – Quentin