Jump to content

Should my address look like this?


komquat

Recommended Posts

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.

I.e

www.mysite.com/index.php?action=showpage


would mean:

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

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

i.e

www.mysite.com/index.php?show=comments&id=6

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

$_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.
[code]
<a href='index.php?show=comments&id=6'>link</a>
[/code]
Of course you can (and most of the time, probably will be) using variables in the url
[code]
<a href='index.php?show=$show&id=$id'>link</a>
[/code]

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!

Archived

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

×
×
  • Create New...

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.