View Full Version : How do I prevent none members from downloading files and direct them to register.php

06-23-2010, 10:15 PM
I have an html web page with files that anyone at this point can download without loggin in. I want users that have not registered or logged in to be redirected to either the login page, which if they dont have a login, then they will have to register and then loggin. Once they login, I want them to be able to download the files of their choice.

The reaper
06-23-2010, 10:57 PM
Do you have code to start with?

For starters change the extension of .html to .php. Then have a session variable with an else statement that will show the content when there is a active user session. If there is not a session, just use headers to redirect the viewer.

06-23-2010, 11:08 PM
I don't think that will help if the path is already known. An intermediate download script that "hides" the files/paths would be necessary, unless I'm mistaken.

06-23-2010, 11:30 PM
Have a download button that passes a variable off to a second php page that process that variable into a download url and redirects to that url? I'm sure there is some apache way to do it too though.

06-24-2010, 01:36 AM
Check if a variable (username) or something similar is set, if not, redirect to the page of your choice.

06-24-2010, 04:25 AM
Check if a variable (username) or something similar is set, if not, redirect to the page of your choice.

That also won't work if the file path is known.

06-24-2010, 09:05 AM
I'm sorry, do you mean conceal a downloads path? I was simply talking about him wanting to redirect to a login/register page.

06-24-2010, 01:26 PM
That was my interpretation of his root problem. I think his main issue is to restrict access to the files. The login redirect would be part of it, though.

06-24-2010, 02:11 PM
You can tell the script to only download the file if the user is logged in and not just a visitor and you can also use .htaccess to stop anyone accessing the folder which holds all down loadable files.

06-24-2010, 03:15 PM
You can have a PHP snippet in the download page to check if the user has access to the download page.