CH 4 Pg 143 HTMLSpecialChars
I have a little problem.
When I test my form ( this is working with the Loan page, checking to see if fields are filled in properly), it correctly removed the html characters I entered into the name field but, the age field is incorrect.
Notice down on the first "if" field. I added "You entered: " to this script because no matter what number I entered it always says go back. I do not know why. For example, if you enter in 25, which is above and below the accpeted limits, my page says "You entered: age".
It is printing out the name of the variable, not the variable itself.
<?php
$_POST["firstname"] = HTMLSpecialChars("firstname") ;
$_POST["lastname"] = HTMLSpecialChars("lastname") ;
$_POST["age"] = HTMLSpecialChars("age") ;
$_POST["address"] = HTMLSpecialChars("address") ;
if ($_POST["age"] < 10 or $_POST["age"] > 140)
{
echo "Your entered: $_POST[age] <br />";
echo "Incorrect Age entered - Press back button to try again.";
exit;
}
if ($_POST["firstname"] == "" or $_POST["lastname"] == "")
{
echo "You must enter you name - Press back button to try again.";
exit;
}
if ($_POST["address"] = "")
{
echo "You must enter your address - Press back button to try again.";
exit;
}
if ($_POST["loan"] != 1000 and $_POST["loan"] != 5000 and $_POST["loan"] = 10000)
{
echo "You must enter a loan value - Press back button to try again.";
exit;
}
$SalaryAllowance = $_POST["salary"] / 5;
$AgeAllowance = ($_POST["age"] / 10 - ($_POST["age"] % 10) / 10 ) -1;
$LoanAllowance = $SalaryAllowance + $AgeAllowance;
echo "Loan desired: $_POST[loan] <br /> " ;
echo "Loan amount we will allow: $LoanAllowance <br /><br />";
if ($_POST["loan"] <= $LoanAllowance) echo "Yes, $_POST[firstname] $_POST[lastname], we are delighted to accept your application. ";
if ($_POST["loan"] > $LoanAllowance) echo "We\"re sorry, $_POST[firstname] $_POST[lastname], we cannot accept your application at this time.";
?>
|