PHP Post Method

on Sunday, November 11, 2012

POST:

‘POST’ is used for the value sending . the values sent that aren’t  appears in url bar.Generally used for login and security.

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 post method</title>
</head>

<body>
<form action="action.php" method="post" name="passing value by post">
<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=$_POST['name'];
$var2=$_POST['age'];
echo "welcome".$var1."&nbsp; your age is ".$var2;
?>

Now copy these two files to your php server and run “test.php” in browser