Re: Where and how do i use $_post etc
| From: | Al | Date: | Fri, 26 Dec 2003 10:46:56 +0000 |
| Subject: | Re: Where and how do i use $_post etc | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173331@lists.php.net to get a copy of this message | ||
"Piet" <pieterdt@telkomsa.net> wrote in message
news:20031226092043.53949.qmail@pb1.pair.com...
> Hi
>
> I am trying to find examples of how and where to use $_POST, $_GET etc. I
> searched a lot of places, but cant seem to find decent examples or a
> tutorial or something.
$_POST and $_GET are associative arrays containing the form data sent by a
user to a page. Whether your user's submitted form data is in $_POST or
$_GET depends on what method attribute you've specified in the <form> tag in
your HTML code. Take a look at the following HTML example:
<form method="get" action="script.php">
<input type="text" name="firstName">
<input type="text" name="lastName">
<input type="submit">
</form>
Now in the file script.php you can access the submitted form values in the
$_GET array, using the form field names as array keys. e.g:
<?php
$firstName = $_GET['firstName'];
$lastName = $_GET['lastName'];
echo 'The user submitted the name'.$firstName.' '.$lastName;
?>
If you had set the <form method="post"> in your HTML, then you could have
accessed the form values from the $_POST array within PHP.
Hope that helps,
Al