MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

PHP Programing language

Get & Post in PHP
Previous Home Next

Get & Post Methods

In forms, you want to submit the information and transfered the information to another page. The following to methods are used for this:

  1. The GET Method : In this method, the key values are passed in the Url.
  2. The POST Method : In this method, the information transfers in a hidden manner.
GET Method:

In Client side, method="get" is used to submit information in a form. And In Server side, $_GET associative array is used to receive sent information in a form.

Example:

test.php code:

<html>
<head>
<title>Get method in PHP</title>
</head>
<body>

<form action="abc.php" method="GET">
Your Name : <input type="text" name="yourname"/><br/><br/>
Your Age :  <input type="text" name="yourage" /><br/><br/>
<input type="submit" />
</form>
</body>
</html>
abc.php code:

<?php
if( $_GET["yourname"] || $_GET["yourage"] )
{
echo "Welcome". $_GET['yourname']. "<br />";
echo "You age is ". $_GET['yourage']. " years.";
exit();
}
?>

 

Output:

Before Submit Information:

After Submit Information:

POST Method:

In Client side, method="post" is used to submit information in a form. And In Server side, $_POST associative array is used to receive sent information in a form.

Example:

test.php code:

<html>
<head>
<title>Post method in PHP</title>
</head>
<body>
 
<form action="abc.php" method="POST">
Name: <input type="text" name="name"/><br/><br/>
Age: <input type="text" name="age"/><br/><br/>
<input type="submit" />
</form>

</body>
</html>
abc.php code:

<?php
if( $_POST["name"] || $_POST["age"] )
{
echo "Welcome ". $_POST['name']. "to our world...!!!<br />";
echo "You are ". $_POST['age']. " years old.<br/>";
echo "You permitted to enter this world."; 
exit();
  }
?>

Output:

Before Submit Information:

After Submit Information:

The $_REQUEST variable

The $_REQUEST variable is a superglobal Array that contains the contents of both $_GET, $_POST, and $_COOKIE arrays. It can be used to collect data sent with both the GET and POST methods.

Example:

test.php code:

<html>
<head><title>$_REQUEST Variable in php</title>
</head>
<body>

<form action="abc.php?thename=MarPlo" method="post">
 <input type="text" name="thename" value="r4r.co.in" />
 <input type="submit" value="Send" />
</form>
</body>
</html>
abc.php code:

<?php
if(isset($_REQUEST['thename'])) 
echo $_REQUEST['thename'];       
?>

Output:

Before Submit:

After Submit:

Previous Home Next