Ok. So I'll goto a new page when successful, and start by validating in php. (Will try javascript validation when I've got this right).
I'm a relative oldie who left uni before object-oriented stuff came in, so please forgive the top-down approach. (Long live Pascal and PL/1)
The page to display the form will be formpage.php.
If they enter it right, it will redirect to newpage.php.
So in formpage.php:
if details-entered
then validate form.
if valid-form
then send-email
if email-sent-ok
then goto successpage
(header(location: newpage)
else set error message
else (invalid-form)
set field error messages
......
display form (action=formpage.php)
hidden field details-entered set to true
Is this how to structure it? The idea of validating before displaying the actual form seems wierd.
I'm learning PHP from a QuickStart book at home, so haven't been able to look over the shoulder of people coding PHP nicely.
When I re-enter formpage.php upon actioning the form, will I run into the problem that the fields entered will be reset to blank?
All this validation code at the top is so search-engine unfriendly, too.
Am I approaching this correctly?
|