PHP Form Handling Tutorial Online | Coding Tag
×

PHP Form Handling

4176

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.

<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.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments