Page Access

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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


  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

Re: Page Access

Jerim79 wrote:
Quoted text here. Click to load it

Well, it sounds like you probably used:


Which could work enough for you.
Personally, I would either
- require the submit button from the previous form (for instance
- 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

Site Timeline