PHP form Processing
Form instance:
<html>
<body>
<form action= "welcome.php" method= "POST" >
Name: <input type= "text" name= "name"/>
Age: <input type= "text" name= "age"/>
<input type= "Submit"/>
</form>
</body>
The HTML page example above </html> contains two input boxes and a submit button. When the user fills out the form and clicks the Submit button, the form's data is sent to the "welcome.php" file.
The "welcome.php" file looks like this:
<html>
<body>
Welcome <?php echo $_post["name";? >.<br/>
You are <?php echo $_post[' age ';?> perton old.
</body>
</html> the output sample from the script above is similar to this:
Welcome John.
You are are Perton old.
We'll explain PHP $_get and $_post in the next chapter.
Form validation
User input should be validated whenever possible. The client is validated faster and can reduce the load on the server.
However, any traffic is so high that you have to worry about the server resources of the site, it is also necessary to worry about the security of the site. If the form accesses a database, it is very necessary to use server-side validation.
A good way to validate a form on the server is to conveys it to itself rather than jump to a different page. This allows the user to get an error message on the same form page. Users are also more likely to find errors.