我建立了一个应用程序来预测商学院入学。我正在添加功能来更改计算器的输入,而无需重新开始。我有两个页面update_gmat.php和update_round.php。所有变量都在update_gmat.php上正确加载,但如果我在update_round.php上,然后再次更改Round并返回到update_round.php,那么Round会话变量将变为空白。我可以设置Round会话变量,它可以在第一次加载时工作但在我转到下一页时消失。我有大约25个会话变量,Round是唯一消失的。
这是update_gmat.php:
<?php
require_once "dbconnect2.php";
require_once "functions.php";
session_start();
$EMAIL = $_SESSION["EMAIL"];
$NEW_GMAT = $_POST["newGmat"];
$OLD_GMAT = $_SESSION["GMAT"];
$GPA = $_SESSION["GPA"];
$WORK = $_SESSION["WORK"];
$MAJOR = $_SESSION["MAJOR"];
$INDUSTRY = $_SESSION["INDUSTRY"];
$AGE = $_SESSION["AGE"];
$COUNTRY = $_SESSION["COUNTRY"];
$ROUND = $_SESSION["ROUND"];
$verify_variables = verifyInputs($OLD_GMAT, $GPA, $WORK, $AGE, $EMAIL, TRUE);
$verify_gmat = verifyGMAT($NEW_GMAT);
if($verify_gmat == "True") {
if($verify_variables == "True") {
$_SESSION["GMAT"] = $NEW_GMAT;
$st_row = '<tr style="border-top: none; border-bottom: none;">';
$st_cell = '<td style="border-top: none; border-bottom: none;">';
$er = '</tr>';
$ec = '</td>';
echo '<table style="border-top: none; border-bottom: none;">
<tbody style="border-top: none; border-bottom: none;">';
echo $st_row . $st_cell . '<center>School</center>' . $ec;
echo $st_cell . '<center>GMAT: ' . $NEW_GMAT . '</center>' . $ec;
echo $st_cell . '<center>GMAT: ' . $OLD_GMAT . '</center>' . $ec . $er;
if($_SESSION["HARVARD"]) {
echo $st_row;
echoCell("Harvard");
echoCell(processHarvard($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processHarvard($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["STANFORD"]) {
echo $st_row;
echoCell("Stanford");
echoCell(processStanford($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processStanford($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["WHARTON"]) {
echo $st_row;
echoCell("Wharton");
echoCell(processWharton($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processWharton($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["BOOTH"]) {
echo $st_row;
echoCell("Booth");
echoCell(processBooth($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processBooth($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["SLOAN"]) {
echo $st_row;
echoCell("Sloan");
echoCell(processSloan($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processSloan($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["KELLOGG"]) {
echo $st_row;
echoCell("Kellogg");
echoCell(processKellogg($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processKellogg($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["HAAS"]) {
echo $st_row;
echoCell("Haas");
echoCell(processHaas($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processHaas($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["COLUMBIA"]) {
echo $st_row;
echoCell("Columbia");
echoCell(processColumbia($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processColumbia($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["TUCK"]) {
echo $st_row;
echoCell("Tuck");
echoCell(processTuck($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processTuck($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["NYU"]) {
echo $st_row;
echoCell("NYU");
echoCell(processNYU($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processNYU($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["ROSS"]) {
echo $st_row;
echoCell("Ross");
echoCell(processRoss($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processRoss($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["YALE"]) {
echo $st_row;
echoCell("Yale");
echoCell(processYale($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processYale($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["DARDEN"]) {
echo $st_row;
echoCell("Darden");
echoCell(processDarden($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processDarden($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["DUKE"]) {
echo $st_row;
echoCell("Duke");
echoCell(processDuke($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processDuke($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["CORNELL"]) {
echo $st_row;
echoCell("Cornell");
echoCell(processCornell($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processCornell($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
if($_SESSION["MCCOMBS"]) {
echo $st_row;
echoCell("McCombs");
echoCell(processDarden($NEW_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echoCell(processDarden($OLD_GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $ROUND));
echo $er;
}
echo '</tbody>
</table>';
echo '<form action="update_gmat.php" method="post">';
echo '<div style="margin-top: 15px">Update GMAT:</div>
<div><input type="text" name="newGmat" /></div>';
echo '<input value="Change GMAT" type="submit"><br><br>';
echo '</form>';
echo '<form action="update_round.php" method="post">';
echo '<div style="margin-top: 15px">Update Application Round:</div>
<div><select name="newRound">
<option value="Round 1">Round 1</option>
<option value="Round 2">Round 2</option>
<option value="Round 3">Round 3</option>
<option value="Round 4">Round 4</option>
</select></div> ';
echo '<input value="Change Round" type="submit">';
echo '</form>';
}
else
{
echo "Email: " . $EMAIL . "<br>";
echo "New GMAT: " . $NEW_GMAT . "<br>";
echo "Old GMAT: " . $OLD_GMAT . "<br>";
echo "GPA: " . $GPA . "<br>";
echo "Work Exp: " . $WORK . "<br>";
echo "Major: " . $MAJOR . "<br>";
echo "Industry: " . $INDUSTRY . "<br>";
echo "Age: " . $AGE . "<br>";
echo "Country: " . $COUNTRY . "<br>";
echo "Round: " . $ROUND . "<br>";
}
}
else
{
echo $verify_gmat;
echo 'You enterered a GMAT of "' . $NEW_GMAT . '"<br>';
echo '<form action="update_gmat.php" method="post">';
echo '<div style="margin-top: 15px">Enter Legitimate GMAT Score:</div>
<div><input type="text" name="newGmat" /></div>';
echo '<input value="Change GMAT" type="submit"><br><br>';
echo '</form>';
echo '<form action="update_round.php" method="post">';
echo '<div style="margin-top: 15px">Update Application Round:</div>
<div><select name="newRound">
<option value="Round 1">Round 1</option>
<option value="Round 2">Round 2</option>
<option value="Round 3">Round 3</option>
<option value="Round 4">Round 4</option>
</select></div> ';
echo '<input value="Change Round" type="submit">';
echo '</form>';
}
echo "<br><br>";
?>
我在update_round.php中添加了一堆echo语句,以查看会话变量何时具有值。 这是update_round.php:
<?php
session_start();
require_once "dbconnect2.php";
require_once "functions.php";
echo "Session Round = " . $_SESSION["ROUND"] . "<br>";
echo "Email: " . $_SESSION["EMAIL"] . "<br>";
echo "GMAT: " . $_SESSION["GMAT"] . "<br>";
echo "GPA: " . $_SESSION["GPA"] . "<br>";
echo "Work Exp: " . $_SESSION["WORK"] . "<br>";
echo "Major: " . $_SESSION["MAJOR"] . "<br>";
echo "Industry: " . $_SESSION["INDUSTRY"] . "<br>";
echo "Age: " . $_SESSION["AGE"] . "<br>";
echo "Country: " . $_SESSION["COUNTRY"] . "<br>";
$EMAIL = $_SESSION["EMAIL"];
$GMAT = $_SESSION["GMAT"];
$GPA = $_SESSION["GPA"];
$WORK = $_SESSION["WORK"];
$MAJOR = $_SESSION["MAJOR"];
$INDUSTRY = $_SESSION["INDUSTRY"];
$AGE = $_SESSION["AGE"];
$COUNTRY = $_SESSION["COUNTRY"];
$OLD_ROUND = $_SESSION["ROUND"];
$NEW_ROUND = $_POST["newRound"];
echo "Session Round = " . $_SESSION["ROUND"] . "<br>";
echo "Old Round = " . $OLD_ROUND . "<br>";
$verify_variables = verifyInputs($GMAT, $GPA, $WORK, $AGE, $EMAIL, TRUE);
if($verify_variables == "True") {
echo "Session Round = " . $_SESSION["ROUND"] . "<br>";
echo "New Round = " . $NEW_ROUND . "<br>";
$_SESSION["ROUND"] = $NEW_ROUND;
echo "New Round = " . $NEW_ROUND . "<br>";
echo "Session Round = " . $_SESSION["ROUND"] . "<br>";
$st_row = '<tr style="border-top: none; border-bottom: none;">';
$st_cell = '<td style="border-top: none; border-bottom: none;">';
$er = '</tr>';
$ec = '</td>';
echo '<table style="border-top: none; border-bottom: none;">
<tbody style="border-top: none; border-bottom: none;">';
echo $st_row;
echo echoCell("School");
echo echoCell($NEW_ROUND);
echo echoCell($OLD_ROUND);
echo $er;
if($_SESSION["HARVARD"]) {
echo $st_row;
echoCell("Harvard");
echoCell(processHarvard($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processHarvard($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["STANFORD"]) {
echo $st_row;
echoCell("Stanford");
echoCell(processStanford($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processStanford($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["WHARTON"]) {
echo $st_row;
echoCell("Wharton");
echoCell(processWharton($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processWharton($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["BOOTH"]) {
echo $st_row;
echoCell("Booth");
echoCell(processBooth($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processBooth($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["SLOAN"]) {
echo $st_row;
echoCell("Sloan");
echoCell(processSloan($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processSloan($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["KELLOGG"]) {
echo $st_row;
echoCell("Kellogg");
echoCell(processKellogg($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processKellogg($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["HAAS"]) {
echo $st_row;
echoCell("Haas");
echoCell(processHaas($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processHaas($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["COLUMBIA"]) {
echo $st_row;
echoCell("Columbia");
echoCell(processColumbia($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processColumbia($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["TUCK"]) {
echo $st_row;
echoCell("Tuck");
echoCell(processTuck($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processTuck($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["NYU"]) {
echo $st_row;
echoCell("NYU");
echoCell(processNYU($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processNYU($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["ROSS"]) {
echo $st_row;
echoCell("Ross");
echoCell(processRoss($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processRoss($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["YALE"]) {
echo $st_row;
echoCell("Yale");
echoCell(processYale($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processYale($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["DARDEN"]) {
echo $st_row;
echoCell("Darden");
echoCell(processDarden($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processDarden($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["DUKE"]) {
echo $st_row;
echoCell("Duke");
echoCell(processDuke($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processDuke($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["CORNELL"]) {
echo $st_row;
echoCell("Cornell");
echoCell(processCornell($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processCornell($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
if($_SESSION["MCCOMBS"]) {
echo $st_row;
echoCell("McCombs");
echoCell(processDarden($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $NEW_ROUND));
echoCell(processDarden($GMAT, $GPA, $WORK, $MAJOR, $INDUSTRY, $AGE, $COUNTRY, $OLD_ROUND));
echo $er;
}
echo '</tbody>
</table>';
echo '<form action="update_gmat.php" method="post">';
echo '<div style="margin-top: 15px">Update GMAT:</div>
<div><input type="text" name="newGmat" /></div>';
echo '<input value="Change GMAT" type="submit"><br><br>';
echo '</form>';
echo '<form action="update_round.php" method="post">';
echo '<div style="margin-top: 15px">Update Application Round:</div>
<div><select name="newRound">
<option value="Round 1">Round 1</option>
<option value="Round 2">Round 2</option>
<option value="Round 3">Round 3</option>
<option value="Round 4">Round 4</option>
</select></div> ';
echo '<input value="Change Round" type="submit">';
echo '</form>';
echo "Session Round = " . $_SESSION["ROUND"] . "<br>";
}
else
{
echo "Email: " . $EMAIL . "<br>";
echo "GMAT: " . $GMAT . "<br>";
echo "GPA: " . $GPA . "<br>";
echo "Work Exp: " . $WORK . "<br>";
echo "Major: " . $MAJOR . "<br>";
echo "Industry: " . $INDUSTRY . "<br>";
echo "Age: " . $AGE . "<br>";
echo "Country: " . $COUNTRY . "<br>";
echo "Round: " . $ROUND . "<br>";
}
echo "<br><br>";
?>
当我从计算器转到update_round.php时,它会在第一次加载时运行,然后圆形会话变量消失。当我从update_gmat.php转到update_round.php时,它在第一次加载时工作,然后圆形会话变量消失。一旦Round会话变量停止工作,即使我回到update_gmat.php并返回,它仍然无法工作。
在原始计算器中,我从HTML表单帖子中设置了回合:
$_SESSION["ROUND"] = $_POST["inputRound"];
以下是update_gmat.php到update_round.php的输出:
以下是从update_round.php开始并返回update_round.php的输出:
我已经谷歌搜索了这个没有运气的问题。任何帮助都会很棒。我很想在Stack Overflow上发帖,很抱歉如果我没有正确提交问题。我经常使用旧问题寻求帮助,但这是我第一次找不到有类似问题的人。