Forum Moderators: coopster

Message Too Old, No Replies

Redirecting with an alert message

...

         

mikejson

8:27 pm on Aug 11, 2003 (gmt 0)

10+ Year Member



What I want to do is use PHP to decide if a webpage is allowed to be viewed. This will just be a gateway type page which will do the decision if the user can go to the page. I am doing it this way because I want them to be able to get to the page... only by URL(just in case there is a special circumstances).

Anyway, I want to put up an alert box(like Javascript) stating why it's not reachable, and then reload the previous page. Is there any way I can do this without having an intermediate page giving the response.

coopster

8:39 pm on Aug 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use PHP to form up your "reloaded" page which could include a <SCRIPT> block with a function that simply displays an alert message after the page loads.

vincevincevince

10:03 pm on Aug 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



in the 2nd page, put something like:]

if ($wrongroutetest)
{
echo"<script language=\"javascript\">document.alert(\"etc\")</script>";
die();
}

out of interest...
...HOW will you know how they got there?

mikejson

1:15 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



Oh, basically I'm using this page to verify a specific time block Sept-Dec of each year. The actual page it is going to load up in that time block will still be reachable from the URL. I just don't want visitors to the site to link to it through our page if it's out of that time block. But we can still direct them to the URL if we want them to use this form.

This php script will just check the date, if it's say Sept 3, it will just load the page, if it's say Jan 1, it will give an alert and reload the previous page.

mikejson

1:17 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



You could really use the HTTP_REFERER if you were wanting to know how they got there.... but I'm not caring how they get the the actual page. :)

coopster

4:25 pm on Aug 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Actually, using HTTP_REFERER is not a good practice. First off, it can be spoofed. Secondly it can be turned off by the user agent. And lastly, never trust browser-supplied variables. A quick search on the net for "HTTP REFERER" will give you loads of information on this practice.