我使用PHP和MySQL制作了一个登录表单。但是,当我输入错误的登录信息时,我遇到了错误。
<?php
while($row = mysql_fetch_array($result))
{
if($result)
{
header('Location: supplementsstore.php');
}
else
{
header('Location: logon.php');
}
}
?>
if
按预期工作,但它不会执行else
语句。
我已尝试将其他内容更改为!$result
,但这也无效。
答案 0 :(得分:2)
如果要将if($result)
评估为false,则永远不会输入while循环。
所以试试:
if( count($row) > 0 )
而不是
if($result){}
答案 1 :(得分:0)
if($row = mysql_fetch_array($result))
{
header('Location: supplementsstore.php');
}
else
{
header('Location: logon.php');
}