HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |
| ||||
PHP Forms and User Input
PHP Forms and User InputThe PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. PHP Form HandlingThe most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.ExampleThe example below contains an HTML form with two input fields and a submit button:
When a user fills out the form above and click on the submit button, the form data is sent to a PHP file, called "welcome.php": "welcome.php" looks like this:
Output could be something like this:
The PHP $_GET and $_POST functions will be explained in the next chapters. Form ValidationUser input should be validated on the browser whenever possible (by client scripts). Browser validation is faster and reduces the server load. You should consider server validation if the user input will be inserted into a database. A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This makes it easier to discover the error. |
© 2011 d4download.orgfree, All Rights Reserved.
Design created by diljith d4download veriosn 2.0
HOME | basics of HTML | basics of PHP | neobux | onbux | readbud | templates |