Registered users only can download

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    Registered users only can download

    I need php code that deny any user to download the files in the site except the registerd users can download the files how can i do that with php or any language?
  • nothing1
    New Member
    • Nov 2007
    • 30

    #2
    Originally posted by smartic
    I need php code that deny any user to download the files in the site except the registerd users can download the files how can i do that with php or any language?
    In what way are the users logged in? sessions or cookies? either way this might help:


    [PHP]//the blank space is where it changes depending on sessions or cookies.
    if( _______ != ''){
    $logged_in = 'true';
    }else{
    $logged_in = 'false';
    }


    //in the body where ever the download link is
    <?php
    if($logged_in){ echo '<a href="http://mysite.com/donwload/file.zip">Downl oad</a>';}
    ?>[/PHP]

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Originally posted by nothing1
      In what way are the users logged in? sessions or cookies? either way this might help:


      [PHP]//the blank space is where it changes depending on sessions or cookies.
      if( _______ != ''){
      $logged_in = 'true';
      }else{
      $logged_in = 'false';
      }


      //in the body where ever the download link is
      <?php
      if($logged_in){ echo '<a href="http://mysite.com/donwload/file.zip">Downl oad</a>';}
      ?>[/PHP]
      TRUE, FALSE or NULL should never be writtin within qoutes - unless you want the TRUE, FALSE or NULL to breated treated as text.

      Doing what you have done
      [php]
      $logged_in = 'true'
      //wont check for boolean TRUE or FALSE
      //but will assign the text 'true' to that variable

      $logged_in = true;
      //however, will give the variable a booleab TRUE.
      [/php]

      Comment

      Working...