Hi, Guest ~ Login or Register

Using $_GET

Using $_GET

Listed In PHP and MySQL » General Development — Viewing Full Tutorial
$_GET is the function that takes out variables from a URL. For example, let's take this URL here and break it down:
www.avengex.com/?go=tutorials&to=viewcat&catid=6
You'll notice there are equals signs between two pieces of text. The part on the left hand side of the equation is the variable name. So, if you parsed ths URL with a php script looking like this:
<?php
echo $_GET[go];
?>
It would come out with "tutorials". In the URL above, you have the following variables inside $_GET[]. These are:
$go
$to
$catid

This is very good for actions pages without forms. It's similar to $_POST, but instead of the data being sent through a form it is sent through the URL. The $_GET method is vital for uses of most CMS operations. For viewing threads you'd assign an ID to the end of the URL, and then you'd take the ID out of the URL with $_GET, and then go to the database and select the thread with that ID.

Remember, similar to $_POST, $_GET is a gate which can be opened for hackers and script kiddies to SQL inject your database, so I suggest you look at a2z's tutorial on cleaning out user inputs before you do anything with the database.

Working Beta

  1. The Forums
    These are mostly functional. If you see any weird bugs, post a thread about it and an administrator will do something.
  2. Tutorial Writing
    You can now submit tutorials to the brand new management system.
  3. Tutorials Home
    View tutorials by categories and search for them here.
  4. Shoutbox
    See below. Registered users only!

Register

Newest User

Say hi to Lirette25! Lirette25 joined on Monday, 14th July.

Sponsor

Check out Next day fake id

Shoutbox