我的代码有问题。当我单击“提交”时,错误检查工作正常,但以前的值消失了。我的代码有什么问题?谢谢
<?php
$FnameErr = $LnameErr = $GenderErr = $TimeErr = $EduErr = $ApatErr = $QuoteErr = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST["Fname"]))
{
$FnameErr = "Enter First Name";
}
else
{
$Fname = $_POST["Fname"];
}
if(empty($_POST["Lname"]))
{
$LnameErr = "Enter Last Name";
}
else
{
$Lname = $_POST["Lname"];
}
if(empty($_POST["gender"]))
{
$GenderErr = "Enter Gender";
}
else
{
$gender = $_POST["gender"];
}
if(empty($_POST["living"]))
{
$ApatErr = "Enter living";
}
else
{
$living = $_POST["living"];
}
if(empty($_POST["quote"]))
{
$QuoteErr = "Enter Quote";
}
else
{
$quote = $_POST["quote"];
}
if(empty($_POST["education"]))
{
$EduErr = "Enter Education";
}
else
{
$education = $_POST["education"];
}
if(empty($_POST["TofD"]))
{
$TimeErr = "Enter Time";
}
else
{
$TofD = $_POST["TofD"];
}
if(isset($Fname) && isset($Lname) && isset($gender) && isset($living) && isset($quote) && isset($TofD))
{
echo "Hello, " . $Fname . " " . $Lname . ".<br />";
echo "You are " . $gender . ", and you live in ";
foreach($living as $f)
{
echo $f . "<br />";
}
echo "You're favorite time is " . $TofD . ", and you passed " . $education . "!<br />";
echo "<i>" . $quote . "</i><br />";
}
}
?>