View Full Version : Using $_GET

04-02-2007, 07:42 PM

I want to use the $_GET function more in order to help decrease the number of pages i have on my server.

Basically, i have a function which deletes an item called deleteitem.php, which is display on items.php

What i want to do is, say have items.php?action=deleteitem&&id=$itemid .

But where and how would i write the deleteitem program. Like, i could just grab the variables from the URL and then do the program, but how will the program know when to act? If you don't understand what i'm getting at, sorry!

like, first part of items.php would be:

Display Item
Delete Item

What if the user visits item.php and doesn't want to delete the item but the code is already on items.php and so how do i stop that from happening?

Any help at all would be appriciative!


04-02-2007, 07:46 PM
Yea sure I understand, check it out:

In your items.php page set it up like so.

if(isset($_GET['action'])) {
$action = $_GET['action'];
$action = $default_action;

//then put in code for delete
if($action == "deleteitem" && isset($_GET['id']) && ...) {
//is_num && isnt blank, and w/e other checks you want, maybe verify id existes?
$delete_query "delete from items where id = $id;
} else
if($action == "home")
//show this... etc

Make sense?

04-02-2007, 08:03 PM
Yes i think so! *goes to try* thank you!