PHP Get Method

on Thursday, November 8, 2012

GET

‘GET’ is used for the value sending . the values sent that are appears in url bar.
Here I am going to give an example try it.

// save the below given as “test.php”

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>my Get method</title>
</head>

<body>
<form action="action.php" method="get" name="passing value by get">
<label>Enter Name</label>&nbsp; :<input name="name" type="text" />
<br />
<label> Enter Age</label>&nbsp; :<input name="age" type="text" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>

// save the below given as action.php

<?php
$var1=$_GET['name'];
$var2=$_GET['age'];
echo "welcome".$var1."&nbsp; your age is ".$var2;
?>
Now copy these two files to your php server and run “test.php” in browser