$_POST variable


PHP $_POST is widely used to collect form data after submitting an HTML form with method=“post". $_POST is also widely used to pass variables. post method is very secure for the data submission in the form as it transfers the data in hidden format from page to page(data not show in URL).

Program for assigning $_POST variable.
 <html>
 <body>
 <form name=“f1” method=“post” action="<?php echo
 $_SERVER['PHP_SELF'];?>
 Enter Roll<input type=“text” name=“t1”>
 <input type=“submit” value=“submit”>
 </form>
 <?php
 if ($_SERVER["REQUEST_METHOD"] == "POST")
 {
 // collect value of input field
 $name = $_POST[‘t1'];
 echo $name;
 }
 ?>
 </body>
 </html>