<?php
$output_form= true;
$output_message = "";
$fname = "";
$lname = "";
$address = "";
$city = "";
$state = "";
$zipcode = "";
if (isset($_POST['submit'])) { // data posted
echo "<pre>";
print_r($_POST);
echo"</pre>";
$fname = trim($_POST['fname']);
$lname = trim($_POST['lname']);
$address = trim($_POST['address']);
$city = trim($_POST['city']);
$state = trim($_POST['state']);
$zipcode = trim($_POST['zipcode']);
if (empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['address']) ||
empty($_POST['city']) || empty($_POST['state']) || empty($_POST['zipcode']))
$output_message = "<p> All fields are mandatory </p>";
$output_form = true;
} else {
$output_form = false;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" >
</head>
<body>
<?php
if ($output_form) {
?>
<h1> HTML Forms </h1>
<h2> Customer Entry Form </h2>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data"
name="userform" target="_self">
<?= $output_message ?>
<table>
<tr>
<td>First Name:</td><td> <input name="fname" type="text" value="<?=$fname ?>"/></td>
</tr>
<tr>
<td>Last Name:</td><td> <input name="lname" type="text" value="<?=$lname ?>" /></td>
</tr>
<tr>
<td>Address:</td><td> <input name="address" type="text" value="<?=$address ?>" /></td>
</tr>
<tr>
<td>City:</td><td> <input name="city" type="text" value="<?=$city ?>" /></td>
</tr>
<tr>
<td>State:</td><td> <input name="state" type="text" value="<?=$state ?>" /></td>
</tr>
<tr>
<td>Zip Code:</td><td> <input name="zipcode" type="text" value="<?=$zipcode ?>" /></td>
</tr>
</table>
<input name="submit" type="submit" />
</form>
<?php
{
?>
<h1> Output Form False</h1>
<?php
} // end of/else form output
?>
</body>
</html>
Currently receiving an unexpected End Of File error. I'm not sure why? Am I leaving something in or something out? I'm new to PHP and I cant make sense of why this does not work. I know this is a lot to read but any feedback helps. Hoping it is a simple fix for anyone out there. Thank you in advance!