Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

page does not exist

Featured Replies

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

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 :)

  • Author

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?

Hi Craig,

 

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 :)

  • Author

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

Hi Craig,

 

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!"

  • Author

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

 

 

Cheers

Craig

Hi Craig,

 

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 :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.