Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  • #2
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    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.

  • #3
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Check if a variable (username) or something similar is set, if not, redirect to the page of your choice.

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by xGIHavoc View Post
    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.
    Are you a Help Vampire?

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    I'm sorry, do you mean conceal a downloads path? I was simply talking about him wanting to redirect to a login/register page.

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #9
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    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.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #10
    New Coder
    Join Date
    Jun 2009
    Location
    Manipal
    Posts
    45
    Thanks
    2
    Thanked 3 Times in 3 Posts
    You can have a PHP snippet in the download page to check if the user has access to the download page.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •