September 19, 2017

Core PHP: PHP Forms (7.4)

Forms


Now, when we have an HTML form with the action attribute set to our PHP file, we can access the posted form data using the $_POST associative array.
In the first.php file:
<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br />
Your age: <?php echo $_POST["age"]; ?>

</body>
</html>

The $_POST super global array holds key/value pairs. In the pairs, keys are the names of the form controls and values are the input data entered by the user.
We used the $_POST array, as the method="post" was specified in the form.
To learn more about the form methods, press Continue!

No comments:

Post a Comment