PHP Form Handling

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.

php-handling

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.

<html>
<body>

<form action="page.php" method="post">
Username: <input type="text" name="username"> <br>
E-mail Id: <input type="text" name="emailid"> <br>
<input type="submit">
</form>
</body>

</html>

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

http://www.website-name.com/page.php?yourname=vihaan&emailid=email-id

For any doubt or query you can ask questions through below comment box.




Coding Tag

Coding Tag always happy to serve you in Information Technology (IT). Learn HTML, CSS, Javascript, PHP, Android, Digital Marketing, Latest IT News and many more.

Leave a Reply

avatar
  Subscribe  
Notify of