View Full Version : Can the following be done? Link and password question

07-27-2009, 05:03 AM
Hey Guys,

I have two questions and I am hoping they can be done.

1st - On my site I have a lot of links for software downloads (exe, sometimes a rar or zip file). Is there a way to make it so those links can only work (start download) if clicked on my site? If the link was posted on another forum and was clicked on, the link won't work. Only if clicked on my site? I'm hoping that is possible..

2nd - How do I password protect a page and have it so I can create different user names and passwords for each member I only want to allowed to view that page?

Thanks guys in advanced.

07-27-2009, 09:30 AM
As it seems like you are doing some kind of school/uni/college assignment and show no instigation to research into solutions I will only provide you with the basics. Should you then present code I'll happily help you debug.

You need to look into form posting and parsing using $_POST, I would suggest using md5 or sha1 for password encryption.

for the files, yes its quite easy to do this, you will need .htaccess, and combined with that a file which forwards people to the file so they don't get the true path. This file mustn't work without $_SESSION which you will need to set when someone logs in succesfully.

In short:

1. use $_POST when someone tries to login
2. set $_SESSION with session_start() after succesful login
3. You will need if statements in the second php file to check if the user is logged in when requesting a file.
4. .htaccess to restrict direct access to a directory containing your files.

Hope that helps! :thumbsup:

07-29-2009, 11:01 AM
Perhaps instead of mailing me telling me that what I just said was wrong, you could provide some code you have done? :rolleyes: