Jump to content


Photo

Should my address look like this?


  • Please log in to reply
1 reply to this topic

#1 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 08 March 2006 - 07:25 PM

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!

#2 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 08 March 2006 - 07:49 PM

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
$_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!
call me a safe bet, i'm betting i'm not




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users