I have a simple HTML form. When a user clicks Submit it will do the following: <FORM METHOD="POST" ACTION="whatever.php">
I want my whatever.php script to check the fields from the form (they are ALL required) and if any are NULL, I would like it to return back to the HTML form and display a message on the form telling them what fields need to be taken care of.
Right now I have a form at http://www.mydomain.com/register.html (for example). I have heard you can have a PHP script that actually creates the form dynamically and can display error messages. I can sort of picture how to do this, but my register page is a link (/register.html) off from my home page. It does not seem logical or correct to me to have a link to register.php that generates a register.html. But I might be wrong...
So I really have two questions here:
1). Should I create my form dynamically with PHP?
2). Can someone give an example of the correct way to redirect or re-create the form page based on a missing field? I think I have the beginnings here, correct?
Code: Select all
if ($username == "")
{ //redirect back to register.html or create new form dynamically
}
if ($password == "")
{ //...
}