php if语句在错误处理中

时间:2013-10-30 15:40:15

标签: php if-statement error-handling

出于某种原因,我的错误验证的后半部分无效,除非上半部分错误。看评论。有人可以发现我的错误吗?我不想使用if / elseif,因为如果存在div,我希望在div中打印多个错误。

    // Validation errors        
    if ($user && ($user !== pg_fetch_result($result, 0, 'user_name'))) { 
        echo "<div id='custom'><ul><li><font color='#672330'>&#187</font> The username you entered is invalid. 
              <div id='noteii'>Please go back and re-enter your current username or contact your account representative for assistance.</div></li></ul></div>";
        }
    if ($pass && ($pass !== pg_fetch_result($result, 0, 'user_pass'))) { 
        echo "<div id='custom'><ul><li><font color='#672330'>&#187</font> The password you entered is invalid. 
              <div id='noteii'>Please go back and re-enter your current password or contact your account representative for assistance.</div></li></ul></div>";
        }
    // Now, if the all of the above are error free the next lines don't work?!...But, the next lines do work if either of the above show errors?! :|
    // Validate password(s)
    if ((strlen($newpass) < 5) || (strlen($newpass) > 15)) { 
        echo "<div id='custom'><ul><li><font color='#672330'>&#187</font> The new password you entered is invalid (Password must be 5 to 15 characters, CaSe SeNsItIvE).
              <div id='noteii'>Please go back and re-enter your desired password(s) password or contact your account representative for assistance.</div></li></ul></div>";
        }       
    if ($newpass !== $cfmpass) { 
        echo "<div id='custom'><ul><li><font color='#672330'>&#187</font> The passwords you entered do not match. 
              <div id='noteii'>Please go back and re-enter your desired password(s) or contact your account representative for assistance.</div></li></ul></div>";          
        }
    //

编辑:这段代码实际上包含在父ELSEIF语句中,不确定是否会产生影响......如果发布整个代码会有所帮助,请告诉我。

0 个答案:

没有答案