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”] ;
?>


No Comments Yet so far
Leave a comment



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>