HTML Form Using Post Method
<html> <head> <title>HTML Form</title> </head> <body> <form action="simple.php" method="post"> Name: <input type="text" name="name"> Address: <input type="text" name="address"> <input type="submit"> </form> </body> </html>
<html> <head> </head> <body> Name : <?php echo $_POST["name"]; ?><br /> Address : <?php echo $_POST["address"]; ?> </body> </html>
Name : Rakesh Kumar Address : Delhi
HTML Form using Get Method
<html> <head> <title>HTML Form</title> </head> <body> <form action="simple.php" method="get"> Name: <input type="text" name="name"> Address: <input type="text" name="address"> <input type="submit"> </form> </body> </html>
http://localhost/PHP_Tutorial/simple.html
http://localhost/PHP_Tutorial/simple.php?name=Rakesh+Kumar&address=Delhi
<html> <head> </head> <body> Name : <?php echo $_GET["name"]; ?><br /> Address : <?php echo $_GET["address"]; ?> </body> </html>
get method के Advantages और Disadvantages
post method के Advantages और Disadvantages
Using $_REQUEST Variable
<html> <head> <title>HTML Form</title> </head> <body> <form action="simple.php" method="post"> Name: <input type="text" name="name"> Address: <input type="text" name="address"> <input type="submit"> </form> </body> </html>
<html> <head> </head> <body> Name : <?php echo $_REQUEST["name"]; ?><br /> Address : <?php echo $_REQUEST["address"]; ?> </body> </html>
Output :
Name : Rakesh Kumar Address : Delhi