I am trying to create a form that lets the user know if they didnt enter information when they hit the submit button.
[code]
Assignment2
What's your name?
Writing a form for user input
Please type your first name:
Please type your last name:
Please type your city:
Please type your State:
Please type your Zipcode:
[/code]
[php]
Assignment2
Personal Information
<?php
$chkErrors = FALSE;
if (isset($_POST['fName'])){
echo " please hit the back arrow and enter your name ";
$chkErrors= TRUE;
}
if (isset($_POST['lName'])){
echo " please hit the back arrow and enter your Last Name ";
$chkErrors = TRUE;
}
if (isset($_POST['city'])){
echo " please hit the back arrow and enter your city";
$chkErrors = TRUE;
}
if (isset($_POST['state'])){
echo " please hit the back arrow and enter your state";
$chkErrors= TRUE;
}
if (isset($_POST['zipCode'])){
echo " please hit the back arrow and enter your zipcode ";
$chkErrors= TRUE;
}
$fName = filter_input(INPUT_POST, "fName");
$lName = filter_input(INPUT_POST, "lName");
$city = filter_input(INPUT_POST, "city");
$state = filter_input(INPUT_POST, "state");
$zipCode = filter_input(INPUT_POST, "zipCode");
if($chkErrors == FALSE) {
echo <<<HERE
Hi there, $fName $lName,
so you live in $city,
in the great state of $state.
I hear the climate around $zipCode is great this time of year.
$fName, I hear that $state has alot to offer as far as recreation goes.
I hope that you have a great summer in $city.
HERE;
}
?>
[/php]