473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Registered users only can download

150 100+
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?
Dec 12 '07 #1
2 1822
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">Download</a>';}
?>[/PHP]
Dec 13 '07 #2
Markus
6,050 Expert 4TB
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">Download</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]
Dec 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Derrick | last post by:
We are trying to create a basic "signup for demo download" where user enters info, gets an email with user/pass to go and ftp download the demo. FTP currently is using NT security. Is it possible...
3
by: Lachlan Gemmell | last post by:
Hello there, I'd like to set the users default download folder on their PC to a certain location (if it exists). The users will be downloading documents and we want to try to minimise the...
4
by: Martin Franklin | last post by:
I am trying to get a total record count on a Acess 97 mdb database. However I get the following error when I try to load the page: Provider error '80040154' Class not registered...
11
by: Heather | last post by:
I need suggestions on possible ways to implement the following: 10 users on a network need to infrequently add data to a backend database on the network. The data would be a couple of records...
0
by: znmaster | last post by:
I've made a ActiveX control, and I put it in a web page. When users browser the page , the ActiveX control is downloaded,but not registered in the computer automatically!! When you refresh the...
8
by: DanB | last post by:
This is probably soooo simple but I can't seem to get it. I have a text file that I want users to download via a web page. I want the file to be saved to a default folder (or one that they...
2
by: bjacob | last post by:
Hi! I have a blog made with b2evo, but I'd want to migrate to another software. I need this feature: different user levels, and each level see only the posts intended for them. I'd want to be...
2
by: deko | last post by:
I have files on my Apache web server that are NOT in publicly accessible space. I want to make these files available for download only to authenticated users. I currently use a download script...
10
by: Jamunt | last post by:
Hi, I want to create an application in which around 1000 users will be served at one time. All of the users will be sending around 1 mb of data. I will be parsing that data and would insert some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.