remove all the if
statements therefore you define the variables even if the variable contains no data as in even if the user did not enter any information into that field. Therefore, if the user does not enter their city
, the record would still be inserted into the catalog
table but with an empty value for city
from
if (!empty($_POST['name'])){ $name = $_POST['name'];}
if (!empty($_POST['city'])){ $city = $_POST['city'];}
if (!empty($_POST['country'])){ $country= $_POST['country'];}
if (!empty($_POST['year'])){ $year = $_POST['year'];}
to
$name = $_POST['name'];
$city = $_POST['city'];
$country= $_POST['country'];
$year = $_POST['year'];