PHP Tutorials

March 4, 2008, 12:28 am
Filed under: PHP

This variable is used to get a value from a form. Below is an example:

<form action=”myphp.php” method=”GET”>
Firstname: <input type=”text” name=”firstname” />
Lastname: <input type=”text” name=”lastname” />
<input type=”submit” />

When the user clicks the submit button, it will then display a different URL depending on the user’s input. I’ll use Bryan for first name and King for last name so the URL will look like this:

Now, we can use the two values passed from the form by using the $_GET variable:

echo “Firstname: “ . $_GET[“firstname”] . “<br />”;
echo “Lastname: “ . $_GET[“lastname”] ;

Leave a Comment so far
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: