473,327 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

Dec 13 '06 #1
1 1324
Rik
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
Dec 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: guy | last post by:
I have an htm page which is often visted and it's a very established page and for that reason I cannot change its extension to asp. However, I want to run a bit of VB code on the server whenever...
6
by: Biguana | last post by:
Hi, Just wondering if anyone can help here. We have a site where most of the site opens in a window with no toolbars or menubar: window.open('mypage.aspx','self','toolbar=0, menubar=0, etc,...
2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
8
by: jbonifacejr | last post by:
This is my first day here, so please be patient. I do not know how to search very well so the search I tried to get the answer showed me topics from the year 2000 and they really don't cover what I...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
4
by: lichaoir | last post by:
I have two questions about the use of Master Page: 1. How to access properties and controls in the master page from content page? (I know I can use the "FindControl()" method of the "Master"...
1
by: zlf | last post by:
Hello my website has role based access, and user without specific role assigned cannot access specific page in website. When the user try to access a page who has not been granted to access, the...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
7
by: Andy B | last post by:
I have a class I am creating for data access. I need to access controls from inside the class that are on a particular page. How do I do this? or is creating an instance of the page class and using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.