Jump to content

Should my address look like this?


komquat

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!
Link to comment
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.

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.