我在一页上有这个 php 脚本,它从输入字段中获取变量:
if($fname <> "" and $lname <> "" and $ydept <> "") {
if ($percentage >= "85") {
mail ($myEmail, $mailSubject, $msgBody, $header);
mail ($userEmail, $sentMailSubject, $sentMailBody, $sentHeader);
$filename = "blah.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) . "";
$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: yes.php?fname=$fname&type=$type");
}
else {
header ("Location: didnotpass.php?percent=$percentage&type=$type");
}
}
else {
header ("Location: empty.php?type=$type");
}
didnotpass.php 脚本是:
<?php
if (isset($_GET['type']) && isset($_GET['percentage'])) {
$percent = trim(strip_tags(stripslashes($_GET['percent'])));
$type = trim(strip_tags(stripslashes($_GET['type'])));
if ($type == "Clinical") {
?>
The Certificate of Attendance has been completed yet, but your score of $percent% is less then the passing score of 85%.<br><br>
Please <b><a href="C.php">Click Here</a></b> to retake the certification.
<?php
}
else {
?>
The Certificate of Attendance has been completed yet, but your score of $percent% is less then the passing score of 85%.<br><br>
Please <b><a href="nonC.php">Click Here</a></b> to retake the certification.
<?php
}
}
else {
?>
Please <b><a href="start.php">Go To Certification Homepage</a></b> to start the certification.
<?php
}
?>
我遇到的问题是分数是否为 85%,它转到最后一个 else 语句:
Please <b><a href="start.php">Go To Certification Homepage</a></b> to start the certification.
我的 IF 语句是否正确:
if ($percentage >= "85")
我认为它工作正常,因为它正在路由到正确的页面,但 didnotpass.php 中的 IF/ELSE 语句工作不正常。任何人都可以帮我解决它吗?