Forum Moderators: coopster
In that case I'd seperate out and have one table with usernames/passwords and another with the file name and file description.
create database wordDocs;
use wordDocs;create table users(
username varchar(255),
password varchar(255),
primary key(username)
);
create table docs(
id int not null auto_increment,
filename text,
description test,
primary key(id)
);
<?php
$connection = mysql_connect('mysql_host', 'mysql_user', 'mysql_pass');
mysql_select_db("wordDocs", $connection);
$query = "select filename, description from docs";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo "<a href=\"$row[0]\">$row[1]</a><br>";
}
mysql_free_result($result);
mysql_close();
?>
For an Apache 2 server, relatively easy instructions can be found at
[httpd.apache.org...]
When I enter the correct password, the file does open, but it is unreadable. The possible reason might be that it is in word document format. Do you have any suggestion on how to make the file readable?
My another question is, if I have three files, I need use three include statements and these three files look like one file. Do you have any idea how to make them look like three different files?
Thanks again.
remember:
anything is possible but most things are not advisable ;)
as far as giving a list, are you going to store the filenames in the database?
if so just pull the names from the db and list them on the page they come to after login with a link. Give them an id or something in your db and use that id on the next page to serve up the appropriate document.
tablename = documents
doc_id - integer primary key
doc_name - name of the document
now when they hit the page after login you can do a 'select * from documents' this would give you alist of document names along with their unique id (not advisable forever as the list may get quite long at some point adding a LIMIT and pagination would be fine)
you can then loop through the results, for each one you could echo the document name for the link text and then maybe add the id as a GET parameter that goes to a script that controls the downloading. Each link might look something like
<a href="downloader.php?docid=33">My fancy word doc</a>
then when the link is clicked, the target script can use the docid to query the database, get the doc_name and then serve that document to the user.
the reason I say zip and let them download is because .doc format won't really work, maybe if no one uses anything but IE but there is nothing worse than a site that tells me I have to use IE.
it shows a downloader for a file as csv
you're not doing csv but the steps are similar
just look at the headers it sets and you could just set your filename/path/contents in $output_file
you will need to set headers for zip or doc or whatever you decide as opposed to csv