Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: PHP Action Array  (Read 15460 times)

0 Members and 1 Guest are viewing this topic.

kpac

    Topic Starter
  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
PHP Action Array
« on: June 17, 2008, 09:36:21 AM »
How do you use, or set up an action array like in this forum?
I want to use something like this: "help.php?id=blablabla".

Thanks for any help.

michaewlewis



    Intermediate
  • Thanked: 26
    • Yes
    • Yes
  • Experience: Expert
  • OS: Unknown
Re: PHP Action Array
« Reply #1 on: June 17, 2008, 10:27:42 AM »
it's easy to set one up. You can just create a link on the webpage with the "help.php?id=blablabla"
To retrieve it, use the $_REQUEST variable
http://docs.php.net/manual/en/reserved.variables.request.php
http://docs.php.net/manual/en/language.variables.external.php

kpac

    Topic Starter
  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: PHP Action Array
« Reply #2 on: June 17, 2008, 10:38:38 AM »
Code: [Select]
$actionArray = array(
'activate' => array('Register.php', 'Activate'),
'admin' => array('Admin.php', 'Admin'),
'announce' => array('Post.php', 'AnnounceTopic'),
'ban' => array('ManageBans.php', 'Ban'),
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
'buddy' => array('Subs-Members.php', 'BuddyListToggle'),
'calendar' => array('Calendar.php', 'CalendarMain'),
'cleanperms' => array('Admin.php', 'CleanupPermissions'),
'collapse' => array('Subs-Boards.php', 'CollapseCategory'),
                       // + about 50 more...
);

// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']]))
{
// Catch the action with the theme?
if (!empty($settings['catch_action']))
{
require_once($sourcedir . '/Themes.php');
return 'WrapAction';
}

// Fall through to the board index then...
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';
}

// Otherwise, it was set - so let's go to that action.
require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
return $actionArray[$_REQUEST['action']][1];

This is the SMF code for the actions. I thought it might be complicated like that.

kpac

    Topic Starter
  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: PHP Action Array
« Reply #3 on: June 18, 2008, 08:50:54 AM »
Will you show me how to use this variable? I'm quite new to PHP.

michaewlewis



    Intermediate
  • Thanked: 26
    • Yes
    • Yes
  • Experience: Expert
  • OS: Unknown
Re: PHP Action Array
« Reply #4 on: June 18, 2008, 09:11:23 AM »
Here's an example. It may and it may not work, but it's the general idea. I recommend buying a book about php/mysql. That will help you a lot more than the common method of trying to wade through thousands of useless online tutorials.

Code: [Select]
<?php
if($_REQUEST['urlvariable'] == 'page1'//enter code to go to page 1
else if($_REQUEST['urlvariable'] == 'page2'//enter code to go to page 2
else //enter code to go to default page
?>


kpac

    Topic Starter
  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: PHP Action Array
« Reply #5 on: June 18, 2008, 09:42:42 AM »
I was thinking about buying a book but they're expensive - about €50, or about $80. That's in Ireland anyway - but everything is expensive here.

Thanks for your time and help.

michaewlewis



    Intermediate
  • Thanked: 26
    • Yes
    • Yes
  • Experience: Expert
  • OS: Unknown
Re: PHP Action Array
« Reply #6 on: June 18, 2008, 10:26:00 AM »
have you checked your local library? ;)

kpac

    Topic Starter
  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: PHP Action Array
« Reply #7 on: June 19, 2008, 02:29:40 AM »
No I havent because I dont actually have a local library. I live in the country.

There is one in our nearest town, but its very small.

Just have to rely on CH....  ;D