在我的网站上,我有一个页面,只有在人员详细信息位于名为“成员”的表中时才能查看该页面,这些值是从前一页的表单中发布的。这是我的原始代码,它运行良好:
$query = "SELECT * FROM Members WHERE firstname='" . $firstname . "' and surname='" .
$surname. "'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if ($rows == 1)
{
//user continues loading page
}
else
{
header ('location: signup.html'); //user is redirected to sign up page
}
在对站点进行一些更改后,我现在要求同一用户必须在成员表中具有paid='TRUE' 才能继续加载页面。这是我想出的代码:
$query = "SELECT * FROM Members WHERE firstname='" . $firstname . "' and surname='" .
$surname. "'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
$query = "SELECT paid FROM Members WHERE firstname='" . $firstname . "' and surname='" .
$surname. "'";
$result = mysql_query($query);
$paid = mysql_num_rows($result);
if ($rows == 1 && $paid=='TRUE')
{
//user continues loading page
}
else
{
header ('location: signup.html'); //user is redirected to sign up page
}
使用这个新代码,即使用户已经付费,它也会将他们重定向到注册页面……我是不是走错了路?