当我发布here时,我设法得到了2个我希望用于进一步处理的变量。不幸的是,我无法使用if if语句。
if (isset($_POST['modifybtn'])) { //Now we have our variables all set
$SubmissionID = $_POST['modifybtn'];
$CourseID = $_POST['courseid'];
}
//We do some irrelevant stuff here.... and then
echo $CourseID; //Works
if (isset($_POST['savebtn'])) {
echo $CourseID; //Not Working
saveData($AppID, $CourseID);
header("Location: applicantCase.php");
}
if (isset($_POST['nextbtn'])) {
saveData($AppID, $CourseID);
header("Location: ApplicantApplyEducation.php");
}
为什么会发生这种情况,之前有一行正在发挥作用?
答案 0 :(得分:0)
首先,您可以在if条件之外定义。
$SubmissionID = "";
$CourseID = "";
if (isset($_POST['modifybtn'])) { //Now we have our variables all set
$SubmissionID = $_POST['modifybtn'];
$CourseID = $_POST['courseid'];
}
//We do some irrelevant stuff here.... and then
echo $CourseID; //Works
if (isset($_POST['savebtn'])) {
echo $CourseID; //Now it will Working
saveData($AppID, $CourseID);
header("Location: applicantCase.php");
}
if (isset($_POST['nextbtn'])) {
saveData($AppID, $CourseID); // Now it will work
header("Location: ApplicantApplyEducation.php");
}