Forum Moderators: coopster
I was wondering if anyone had any ideas on how to accomplish this bit of php programming.
What we need is to essentially protect a directory with an interim page. The interim page would have a form asking a yes/no question.
For example:
What we have now..
/ --> /protected_dir/
turns into this:
/ --> interim page (with form) --> /protected_dir/
Optimally, when a person requests a file in the protected directory they would be redirected/prompted by the page with the form on it. Once they answer the question and hit "Submit" they would then be redirected to the page they intially requested.
I've tried .htaccess and $HTTP_REFERER but have had no luck. The $HTTP_REFERER is always the page with the form.
Thanks much. Any advice is GREATLY appreciated.
johnnyeng
Alas, there are PDF's in the directory as well. Do you have any ideas on how to accomplish the goal when PDF's enter the equation? Perhaps an Apache Redirect or .htaccess? I'm stumped!
Thanks much. :)
johnnyeng
By using a combination of .htaccess and $_SERVER['PHP_SELF']; I've managed to echo out the path. I've made a few changes though.
Instead of a form, I now have an image map that counts clicks.
When a user requests a file in the /protected_dir/ they are redirected to a page called 'answer.php', which displays an image map.
Once they click YES/NO, the choice is recorded in MySQL and they "should" go to the page they initially requested....except for one thing. I can't get the 'href' correct.
Here is the code I've been working with:
<?
$referer=$_SERVER['PHP_SELF'];
?>
<map name="Map" id="Yes">
<area shape="poly" coords="96,29,101,66" href="<?php echo $referer;?>" />
<area shape="poly" coords="107,81,126,86,158,86,161,86,180,89,184,42,97,28" href="<?php echo $referer;?>" />
When $referer is echoed out, it looks like this:
/answer.php/protectedfile.php
So I ask this:
Is there any way to replace /answer.php/protectedfile.php
with
/protected_dir/protectedfile.php
when it's echoed out?
Thanks much. I hope that makes sense. :)
johnnyeng