Page Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerim79

    Page Access

    I have a 3 page PHP script. I only want people to be able to access the
    first page of the script by URL. The other 2 pages need to return a
    message such as "This page can not be accessed directly." if someone
    tries to call it up by URL.

    I did this a month or so back using an If statement at the beginning of
    the PHP code. Something along the lines of:

    if (access_method= POST){
    Perform PHP Code
    }

    Else{

    echo "This page can not be accessed directly.";
    }

    I just can remember the correct method to call to check against, and I
    can't find the old script I worked on previously. Any help would be
    appreciated

  • Rik

    #2
    Re: Page Access

    Jerim79 wrote:
    I have a 3 page PHP script. I only want people to be able to access
    the first page of the script by URL. The other 2 pages need to return
    a message such as "This page can not be accessed directly." if someone
    tries to call it up by URL.
    >
    I did this a month or so back using an If statement at the beginning
    of the PHP code. Something along the lines of:
    >
    if (access_method= POST){
    Perform PHP Code
    }
    >
    Else{
    >
    echo "This page can not be accessed directly.";
    }
    >
    I just can remember the correct method to call to check against, and I
    can't find the old script I worked on previously. Any help would be
    appreciated
    Well, it sounds like you probably used:
    if($_SERVER['REQUEST_METHOD ']=='POST'){

    }

    Which could work enough for you.
    Personally, I would either
    - require the submit button from the previous form (for instance
    isset($_POST['go_to_page_2']))
    - or put them all in the same script, just show different sides of it
    according to previous input.

    The latter has the advantage of validating the form in the same script the
    form was in, which allows easy display of the previous form to the user
    with most of the entered values if one or more value are illegal, and
    offcourse noone will ever accidentaly arrive on the wrong page, as it will
    just start with your first form.

    On very large scripts there's something to say for splitting them, but it
    sounds like this is the better choice.
    --
    Rik Wasmus


    Comment

    Working...