Every time you interact with the user through a form, which is a kind of HTML tag containing other form elements such as a list, a textbox, a radio button, etc.
We can generate forms through HTML and use it by integrating with PHP. To collect form data, we should use PHP superglobals $_GET and $_POST. The form request may be get or post.
To retrieve data from the get request, we need to apply $_GET, for post request $_POST. HTML Form integrate with php. How can data transfer from form to php variables.
We can transfer data with two superglobals $_POST and $_GET.
<form action="page.php" method="post">
Username: <input type="text" name="username"> <br>
E-mail Id: <input type="text" name="emailid"> <br>
PHP Page : page.php
<html> <body> <?php echo $_POST['username']; ?> <br> Email id: <?php echo $_POST['email']; ?> </body> </html>
Difference between $_GET and $_POST
If we use the $_GET to transfer the values from html to PHP, then value will be shown in address bar with values, those you put into input fields means publicly show the values, but if we the $_POST then data/value will be invisible and secured as well as no limit to send value/information.
That's why 80% time we use the $_POST super global variable. Through get method you can send approx 100 characters and through post method you can send in bulk values.
Example show like this through get method
For any doubt or query you can ask questions through below comment box.