Trusted answers to developer questions

PHP $_POST

Get Started With Data Science

Learn the fundamentals of Data Science with this free course. Future-proof your career by adding Data Science skills to your toolkit — or prepare to land a job in AI, Machine Learning, or Data Analysis.

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 ©2024 Educative, Inc. All rights reserved
Did you find this helpful?