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?
Registered users only can download
Collapse
X
-
In what way are the users logged in? sessions or cookies? either way this might help:Originally posted by smarticI 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?
[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.Originally posted by nothing1In 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]
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
Comment