Just need some tips on form processing.
I have a simple form to submit name, surname and age. The form is wrapped in a function so can be easily displayed again if a certain field is not completed once the form has been submitted.
At the moment if a field is not completed it displays a message for the field that was not completed. This is fine but I think it looks untidy.
What I would like, is to be able to display the error messages all at once, instead of one at a time as is shown in my code below. So if name, surname, age is not completed it list the error message all at once.
You must enter your name
You must enter your surname
You must enter your age *
This is the code I am using. I know its a bit ropey, but any tips would be really appreciated.
<?php
if (!$_POST['submit'])
{
webform();
} else {
if (!$POST['name']) { echo"You must enter your name<br>"; webform(); exit(); }
if (!$POST['surname']) { echo"You must enter your name<br>"; webform(); exit(); }
if (!$_POST['age']) { echo"You must enter your name<br>"; webform(); exit(); }
echo "Webform Details have been submitted"; }
?>