PHP Post - PHP Tutorial



PHP $_POST

  • PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables.
php-post

Sample Code

<?php
if (isset($_POST["submit"])){
  // collect value of input field
  $name = $_POST['fname'];
  if (empty($name)) {
    echo "Name is empty";
  } else {
    echo $name;
  }
}
?>
<html>
<body>
<form method="post">
  Name: <input type="text" name="fname">
  <input type="submit" name="submit">
</form>
</body>
</html>

Output

php-post

Related Searches to PHP Post