menu

Retrieving Form Data Using the POST Method in PHP

Now let our form be submitted using the POST method:

<form action="/result.php" method="POST"> <input name="test1"> <input name="test2"> <input type="submit"> </form>

In this case, on the result page, the form data will be stored in the variable $_POST:

<?php var_dump($_GET); // empty array var_dump($_POST); // array with keys test1 and test2 var_dump($_REQUEST); // array with keys test1 and test2 ?>

Using a form, ask the user for their name and age. After submitting the form, display this data on the screen.

Let the form ask the user for a password:

<form action="/result.php" method="POST"> <input type="password" name="pass"> <input type="submit"> </form>

Let the correct password be stored in a variable on the result page:

<?php $pass = '12345'; ?>

Make it so that after submitting the form, the password from the variable and the password from the form are compared on the result page. After the comparison, notify the user whether they entered the correct password or not.

Using three inputs, ask the user for their birth year, month, and day. After submitting the form, determine the day of the week on which the user was born.

byenru