You are here: Re: Page Access « PHP Programming Language « IT news, forums, messages
Re: Page Access

Posted by Rik on 12/13/06 19:48

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация