PHP – A Simple HTML Form
The PHP $_GET and $_POST variables are used to retrieve data from forms, like user information.
PHP Form Handling
The most significant thing to see when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.
Example
The example down contains an HTML form with two or more input fields and a submit button:
<html> <body> <form action="test.php" method="post"> Name: <input type="text" name="name"> Phone: <input type="text" name="phone"> <input type="submit"> </form> </body> </html>
When the user fills all the form input fields above and submits the form. After that, the form information is sent to a PHP file, called “test.php“. The form information is transmitted with the HTTP POST method.
“test.php” file looks like this and saves your system:
<html> <body> Welcome <?php echo $_POST["name"]; ?><br> Your phone no is: <?php echo $_POST["phone"]; ?> </body> </html>
Output
Welcome Carrillo
Your phone no is:6579884897
Your phone no is:6579884897