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 ==「#」這意味着用戶沒有從選擇的選項,這將使IF語句失敗,這應該自動把用戶的任何部門到tryagain.php頁面,而是將它們帶到nopass.php頁面。所以它失敗了。IF語句未PHP
我應該嘗試& &,而不是和?但我認爲它不應該有所作爲。
它可以使因爲[運算符優先級(HTTP有所不同:/ /www.php.net/manual/en/language.operators.precedence.php),其中''&&具有比'和'的優先級高。 – ajp15243
但不應該檢查所有條件? – Si8
嘗試'的var_dump($ ydept)'看看會發生什麼。 – Ryan