I am always running into situation where I need to check for empty fields or other validation that needs to have errors return to the user so they know what is wrong before submitting form. What I normally do, is as follows:
$name = $_POST[‘name’];
$state = $_POST[‘state’];
$errors = array();
$errors = “You forgot to fill in your name!”;
$errors = “You forgot to fill in your state!”;
for($i = 0; $i < count($errors); $i++)
Of course I do a little more formatting and such to make errors match the sites specific look and feel, but anyway, just was wondering if there was an easier way then writing an if statement for each field in the html form?
I haven’t thought of a better one or seen one as of yet.