Php登录不执行其他操作

时间:2015-04-03 18:14:02

标签: php mysql

我使用PHP和MySQL制作了一个登录表单。但是,当我输入错误的登录信息时,我遇到了错误。

<?php

    while($row = mysql_fetch_array($result))
    {
    if($result)
      {
       header('Location: supplementsstore.php');
      }
    else
      {
        header('Location: logon.php');
      }
    }

?>

if按预期工作,但它不会执行else语句。 我已尝试将其他内容更改为!$result,但这也无效。

2 个答案:

答案 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');
}
相关问题