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
Page 1 of 1
page does not exist PHP
#2
Posted 14 March 2010 - 11:20 PM
Hi Craig,
You could do something like this in the top of your fail.php file:
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
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
#3
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?
#5
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
line 60 is Xhtml,
Really appreciate your help!!
Cheers
Craig
#6
Posted 14 March 2010 - 11:55 PM
Hi 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!"
craigpettit, 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
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!"
#7
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
Cheers
Craig
#8
Posted 15 March 2010 - 01:44 AM
Hi Craig,
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
craigpettit, 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
Share this topic:
Page 1 of 1
Help
















