Jump to content


This topic is now archived and is closed to further replies.


Should my address look like this?

Recommended Posts

HELP!! I do not know why one would use this, or how to even start using. I am looking for a GOOD tutorial on this and and explaination on why to use it.

Sample code would be great too.

Thanks for all the help in advance!

Share this post

Link to post
Share on other sites
You would generally use this to send information across pages or changing a page's content based upon what follows the "?" in the url.

Basically you are passing data via the URL and then you obtain it using the $_GET superglobal.



would mean:

$_GET["action"] holds the value "showpage"

You can pass more than one piece of info as well, you just need to use '&'



this would result in $_GET containing
$_GET["show"] = "comments"
$_GET["id"] = 6

$_GET is an array so you may view all of it's contents using print_r and of course treat it as you would any other way.

Sending the data to the url is as easy as you might think.
<a href='index.php?show=comments&id=6'>link</a>
Of course you can (and most of the time, probably will be) using variables in the url
<a href='index.php?show=$show&id=$id'>link</a>

One word of warning. If you plan on doing any sql queries based upon information contained in $_GET make sure you have validated and cleaned the info. GET is one of the most open methods of SQL injection that there is.

Hope that helps!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.