Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Pages...

  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pages...

    Ok, so, you know how you can use switch, or if, or arrays to make pages? like act=whateverpage?

    well, can anyone give me a detailed explination of how the arrays method works?


    oh and also, how do you make something like act=page&value=something?


    thanks in advanced.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    querystring: script.php?page=page&action=do&value=whatever is access using the $_GET or $_REQUEST superglobals. Using $_GET['action'] on the above querystring will return a value of 'do' to the value.

    Now, it depends on what you are doing for what would be the best method to use. If your planning on running an include() or require() I'd suggest you use both an array for the pages allowed, and a switch. If your embedding different actions into your script, I'd use an if statement.
    Here's what I mean:
    For inclusions:
    PHP Code:
    <?php
    $allowed_pages 
    = array ('index.php''members.php''news.php');

    if (!empty(
    $_GET['page']) AND in_array($_GET['page'], $allowed_pages))
    {
         include(
    './' $_GET['page']);
    }
    else
    {
         die (
    'The page requested is not available.');
    }
    Not exactly the most secure, but would suffice. Now, for embedded, which is what I use most frequently:
    PHP Code:
    <?php

    if (empty($_REQUEST['action']))
    {
         
    $_REQUEST['action'] = 'default';
    }

    if (
    $_REQUEST['action'] == 'default')
    {
         
    // Default page code
    }
    if (
    $_REQUEST['action'] == 'shownews')
    {
         
    // Show the page news code
    }
    if (
    $_REQUEST['action'] == 'showarticle')
    {
         
    // Show just the article requested (we would need more varibles for this)
    }
    ?>
    Does that help you any?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    actually, not exactly what I was looking for, but I'll use some other resources and work with that.

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •