[SOLVED]?act=stuff if you know what i mean?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

[SOLVED]?act=stuff if you know what i mean?

Post by Diod »

Hey

I dont reallly know how to achieve the thing such as seen on many sites..

like index.php?act=del

i have the following currently

Code: Select all

if(isset($_GET['admin.php?act=post'])) {
}

if(isset($_GET['admin.php?act=edit'])) {
}

if(isset($_GET['admin.php?act=del'])) {
}
Last edited by Diod on Tue Oct 19, 2004 12:25 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php
if($_GET['act'] == 'add'){

//do something

}
elseif($_GET['act'] == 'edit'){

//do something

}
elseif($_GET['act'] == 'del'){

//do something

}
?>
Last edited by John Cartwright on Tue Oct 19, 2004 10:13 am, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

switch($_GET['act']) {
    case 'post':
          // do something
          break;
    case 'edit':
          // do something else
          break;
    case 'del':
          // ...........
          break;
    default:
          header('Location: wrong_act.htm');
}
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

thx.. both :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I recommend a SWITCH in this case.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

ah ok, ill use the switch then :) thx
Post Reply