Wednesday, December 26, 2012
Form Handling in PHP
HOW TO GET USER INPUT
The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
The code for the above pages is a s below.
Implementing using GET method – In page1.php change the method of the form as method=”get”. In page2.php edit $_POST as $_GET. On running the code you will get the output as shown below. Please check the url shown in the output. Values will be displayed in the url.
When to use method="post"? Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.
The PHP $_REQUEST Variable: The $_REQUEST variable can be used to collect form data sent with both the GET and POST methods.