How to use POST Method in php


Post method is the best method to use , it has more advantages then that of disadvantages. Post Method hides the data from normal users. Post Method has no limitations for the string lenght or data limits. Post Method load all the data in the background so normal user cant see any thing. We need to set Post in method for the form.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example for Using POST Method in PHP</title>
<!--We will create one simple form with two fields first name and last name-->
<!--This is the simple example for POST method with form in php-->
<!-- We need to set method="post" for the Get Method-->
<form name="myform" action="" method="post" id="myform">
<label>First Name</label>
<input type="text" name="fname" id="fname" value="" />

<label>Last Name</label>
<input type="text" name="lname" id="lname" value="" />
<input type="submit" value="Submit" name="save" id="save" />

echo 'Your Name-'.$_POST['fname'].' '.$_POST['lname'];