Web Design Forum: page does not exist - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

page does not exist PHP Rate Topic: -----

#1 User is offline   craigpettit 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 174
  • Joined: 11-September 08
  • Reputation: 0
  • Location:Surrey UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:09 PM

Hi,

I have a couple of pages that i do not want to be accessible unless the php directs them there,
for example

failed login, if the user enters an incorrect login detail it takes them to Scripts/fail.php
however
i dont want the user to be able to get Scripts/fail.php by simply typing it into the address bar.

if they type www.example.com/Scripts/fail.php i want it to display a message that reads something like

"this page is not available on the server"

Is there a way to do this

Cheers
Craig
0

#2 User is offline   Japh 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 14-March 10
  • Reputation: 0
  • Gender:Male
  • Location:Australia
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:20 PM

Hi Craig,

You could do something like this in the top of your fail.php file:

<?php
if (empty($_SERVER['HTTP_REFERER'])) {
    header("HTTP/1.0 403 Forbidden");
    exit;
}
?>


However, that will only check to make sure the user hasn't come directly to the script. If they link to it from elsewhere they can still access it, which you could get around by adding a strpos or something to the if() above.

Hope that helps :)
0

#3 User is offline   craigpettit 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 174
  • Joined: 11-September 08
  • Reputation: 0
  • Location:Surrey UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:38 PM

Cheers for the reply mate, however this is just returning errors. i am very new to the php side of things so i may have put it in wrong?
0

#4 User is offline   Japh 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 14-March 10
  • Reputation: 0
  • Gender:Male
  • Location:Australia
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:44 PM

Hi Craig,

View Postcraigpettit, on 14 March 2010 - 11:38 PM, said:

Cheers for the reply mate, however this is just returning errors. i am very new to the php side of things so i may have put it in wrong?


Could you paste the errors here? Then I can help you debug them :)
0

#5 User is offline   craigpettit 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 174
  • Joined: 11-September 08
  • Reputation: 0
  • Location:Surrey UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:48 PM

Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux129/n/nextgensolutions.co.uk/user/htdocs/include/nav.php:55) in /home/fhlinux129/n/nextgensolutions.co.uk/user/htdocs/Scripts/activate.php on line 60


line 60 is Xhtml,

Really appreciate your help!!
Cheers
Craig
0

#6 User is offline   Japh 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 14-March 10
  • Reputation: 0
  • Gender:Male
  • Location:Australia
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 14 March 2010 - 11:55 PM

Hi Craig,

View Postcraigpettit, on 14 March 2010 - 11:48 PM, said:

Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux129/n/nextgensolutions.co.uk/user/htdocs/include/nav.php:55) in /home/fhlinux129/n/nextgensolutions.co.uk/user/htdocs/Scripts/activate.php on line 60


line 60 is Xhtml,

Really appreciate your help!!
Cheers
Craig


Ah ok, the problem is that you need to make sure the code snippet I pasted above is the absolute first thing in your fail.php file. That error is basically telling you "Sorry! I've already sent stuff to the browser, so I can't change the headers now!"
0

#7 User is offline   craigpettit 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 174
  • Joined: 11-September 08
  • Reputation: 0
  • Location:Surrey UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 15 March 2010 - 12:26 AM

thats awesome, it denys access, however it also doesnt allow me to access it if my login fails :|


Cheers
Craig
0

#8 User is offline   Japh 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 14-March 10
  • Reputation: 0
  • Gender:Male
  • Location:Australia
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 15 March 2010 - 01:44 AM

Hi Craig,

View Postcraigpettit, on 15 March 2010 - 12:26 AM, said:

thats awesome, it denys access, however it also doesnt allow me to access it if my login fails :|


Hmm... try echoing $_SERVER['HTTP_REFERER'] instead of the code snippet I provided earlier to see what values it has in different circumstances.

Hard to know without seeing exactly what you're doing now :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users