PHP Tutorials


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

PHP $_GET
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” />
</form>

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:

http://www.myphp.com/myphp.php?firstname=Bryan&lastname=King

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

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

About these ads

Leave a Comment so far
Leave a comment



Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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



Follow

Get every new post delivered to your Inbox.

%d bloggers like this: