Using PHP GET and POST function you can Enter your data and display it. There are two ways to get information from users by creating Simple form and using GET and POST methods. Today I will give an Example of POST function and GET function.

READ MORE :- How to Create Dynamic Website With PHP

php development

POST method

STEP 1 :- Create folder in htdocs and create two pages such as Index.php and welcome.php

STEP 2 :- In Index.php Page paste the below code :

<html>
<body>

<form action=”welcome.php” method=”post”>
Name: <input type=”text” name=”fname”><br>
Age : <input type=”text” name=”age”><br>
<input type=”submit”>
</form>

</body>
</html>

post function in php

STEP 3 :- Now open Welcome.php page and paste the below Code :

<html>
<body>

Welcome <?php echo $_POST[“fname”]; ?>!<br>
You are <?php echo $_POST[“age”]; ?> years old.

</body>
</html>

display post function in php

 

Download-button-tato

GET method

STEP 1 :- Create folder in htdocs and create two pages such as Index.php and welcome.php

STEP 2 :- In Index.php Page paste the below code :

<html>
<body>

<form action=”welcome.php” method=”get”>
Name: <input type=”text” name=”fname”><br>
Age : <input type=”text” name=”age”><br>
<input type=”submit”>
</form>

</body>
</html>

get function in php

 

STEP 3 :- Now open Welcome.php page and paste the below Code :

<html>
<body>

Welcome <?php echo $_GET[“fname”]; ?>!<br>
You are <?php echo $_GET[“age”]; ?> years old.

</body>
</html>

get1_php

Download-button-tato

Difference between GET and POST method

Have you Seen the difference between GET function and POST Function, If not then Just see the URL of both welcome.php page.

–> Using  GET function is not secure Since your Information will appear in URL address. In GET function you can transfer limited data.

–> Using  POST function is secure Since your Information will not appear in URL address. In POST function you can transfer Unlimited data.