PHP $_POST

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>

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved