验证我有一个页面上此PHP脚本这需要从变量输入字段:IF语句不能在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%或不是,它进入最后一条语句:
Please <b><a href="start.php">Go To Certification Homepage</a></b> to start the certification.
是我的IF语句correc T:
if ($percentage >= "85")
我想这是正常工作,因为它被路由到正确的页面,但在didnotpass.php的if/else语句无法正常工作。任何人都可以帮我修复它?
这似乎很容易检查:在'if'条件给你之前'var_dump($ percent);'是什么,你为什么要引用nu MBER? – jeroen 2013-03-11 21:24:06
我的nopass.php网址如下所示:http://www.imed.com/sc/nopass.php?percent=38&type=Clinical – Si8 2013-03-11 21:28:43
你知道,这并不是说这可以解决你的问题,但它可能是一个坏主意在数字周围使用引号。只要做'85'不加引号。 – Mike 2014-04-03 00:52:53