Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
forms

PHP $_POST

Educative Answers Team

PHP $_POST is an associative array of variables passed to the current script via the HTTP POST method.

$_POST is a superglobal variablevariable that is accessible anywhere regardless of scope used to collect form data after submitting an HTML form with method="post".

Example

In this example, we have an HTML form with method="post". The data submitted (the message input) can be accessed once the form is submitted using $_POST['message'].

<?php 
   if(isset($_POST['submit'])){ 
      echo $_POST['message'];
   }
?>
<html>
<body>
   <form method="post" action="">
      <input type="text" name="message">
      <input type="submit" name="submit">
   </form>
</body>
</html>

RELATED TAGS

php
forms
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring