2
if ($fname <> "" and $lname <> "" and $theemail <> "" and $empid <> "" and $doh <> "" and $ydept <> "#") {
    if ($percentage >= 85) {
        mail ($myEmail, $mailSubject, $msgBody, $header);
        mail ($userEmail, $sentMailSubject, $sentMailBody, $sentHeader);
        $filename = "output_annualexam.txt"; #Must CHMOD to 666, set folder to 777
        $text = "\n" . str_pad($fname, 25) . "" . str_pad($lname, 25) . "" . str_pad($empID, 15) . "" . str_pad($doh, 15) . "" . str_pad($tdate, 20) . "" . str_pad($ydept, 44) . "" . str_pad($percentage, 0) . "%";

        $fp = fopen ($filename, "a"); # a = append to the file. w = write to the file (create new if doesn't exist)
        if ($fp) {
            fwrite ($fp, $text);
            fclose ($fp);
            #echo ("File written");
        }
        else {
            #echo ("File was not written");
        }
        header ("Location: congrats.php?fname=$fname&type=$type");
    }
    else {
        header ("Location: nopass.php?percent=$percentage&type=$type");
    }
}
else {
    header ("Location: tryagain.php?type=$type");
}

当 $ydept=="#" 表示用户没有从 SELECT 选项中选择任何部门,这将导致 IF 语句失败,这应该自动将用户带到 tryagain.php 页面,而是将他们带到 nopass。 php页面。所以在某个地方它失败了。

我应该尝试&&而不是AND吗?但我不认为它应该有所作为。

4

1 回答 1

4

是的,你应该使用&&not AND

由于我不够雄辩地解释它,这里有一篇关于它的好帖子,感谢评论员;)

'AND' 与 '&&' 作为运算符

于 2013-06-12T14:51:25.250 回答