0% found this document useful (0 votes)
55 views1 page

Get vs. Post

The document contains an HTML form that collects a user's name and email using input fields and submits via POST to a PHP script. The PHP script echoes the submitted name and email using $_POST to retrieve the form data, welcoming the user. GET and POST both create arrays of key/value pairs from form data that are accessible as the $_GET and $_POST superglobals, with GET via URL parameters and POST via HTTP.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Get vs. Post

The document contains an HTML form that collects a user's name and email using input fields and submits via POST to a PHP script. The PHP script echoes the submitted name and email using $_POST to retrieve the form data, welcoming the user. GET and POST both create arrays of key/value pairs from form data that are accessible as the $_GET and $_POST superglobals, with GET via URL parameters and POST via HTTP.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

<html>

<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>

GET vs. POST


Both GET and POST create an array (e.g. array( key => value, key2 => value2, key3 =>
value3, ...)). This array holds key/value pairs, where keys are the names of the form controls and
values are the input data from the user.
Both GET and POST are treated as $_GET and $_POST. These are superglobals, which means
that they are always accessible.
$_GET is an array of variables passed to the current script via the URL parameters.
$_POST is an array of variables passed to the current script via the HTTP POST method.

You might also like