Page 1 of 1

Code Snipplet Help

Posted: Tue Dec 23, 2003 2:10 am
by John Cartwright
K Guys I've got sort of a nubby question but I have this code that counts download counts but I want to change it from this:

Clicked Link > New Page -Displays Counter & Click to download the file


I have it modified to Display the counter on the first page but I can't seem to skip the download part. Heres what we gotto modify.
In other words I need to so when the first link is clicked the file is downloaded and the counter goes up too.
$include = "file.txt";
$file1 ="http://www.****.com/yourfile1.zip"; //set these to the URLs of the files to be downloaded.
$file2 ="http://www.****.com/yourfile2.zip";
$file3 ="http://www.****.com/yourfile3.zip";
$file4 ="http://www.****.com/yourfile4.zip";
$file5 ="http://www.****.com/yourfile5.zip";
$file6 ="http://www.****.com/yourfile6.zip";
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
$include = "file.txt";
if ($x == 1) {
$filename = "file1.txt";
$fp = fopen( $filename, "r+" ) or die ("no file opening is occuring"); //$fp is short for file pointer
flock($fp,1); //allows file reading but prevents writing
$counter = fgets( $fp, 6 ); //sets variable counter to where filepointer is
$counter++; // increments counter by 1
rewind($fp); // re-sets file pointer to start of file.
fputs( $fp, $counter); //writes the value of the counter to where filepointer is.
flock($fp,3); //releases file
global $file1, $include;
$include = "file1.txt";
print "<p align='center'><a href='$file2'>click to download</a></p>";<---- THIS WHAT WE GOTTO MODIFY

TY IN ADVANCE! :D

Posted: Tue Dec 23, 2003 2:21 am
by aquila125
take a look at header() and instead of outputting html, output the file (read_file_contents)..

Posted: Tue Dec 23, 2003 2:23 am
by John Cartwright
Hey great swift response..

I'm just learning php if you could right the code out for me that'd be great :D

Posted: Tue Dec 23, 2003 8:34 am
by Bill H
You might wash his car too, and maybe walk his dog.

Posted: Tue Dec 23, 2003 10:38 am
by John Cartwright
yea thanks for your help.

I'm sorry I'm not as experience at php as much as you guys..

Like really Bill H, is it so bad to ask for 1 line of code?

Posted: Tue Dec 23, 2003 10:51 am
by Bill H
1) look up header() in php instructions
2) do a search in the forum under "headers AND downloads"

Stop snivelling and do some of the legwork yourself and if there is PART of something that you don't understand ask for help with that part. Asking someone to write code when you have done nothing for yourself is beyond newbie.

Posted: Tue Dec 23, 2003 11:00 am
by John Cartwright
LOL this is too funny, I appreciate your help but I don't appreciate the way you run this place.

I did do some research, and then I decided to come here.

Posted: Tue Dec 23, 2003 12:36 pm
by Draco_03
that ended pretty abrubtly

Posted: Tue Dec 23, 2003 2:09 pm
by d3ad1ysp0rk
lol

he'll be missed :roll:

Posted: Tue Dec 23, 2003 3:14 pm
by McGruff
It might be better to explain the aim of helping people learn rather than merely hand out chunks of code a bit more politely. If someone is new to the forums give them a chance to suss the place out before you start flaming them.

Posted: Tue Dec 23, 2003 3:19 pm
by Draco_03
affirmative

Posted: Tue Dec 23, 2003 3:25 pm
by Bill H
You are, of course, right on McGruff. I usually am more forgiving than that.

It was just the blatancy of his response that got to me. Aquila gave him a very specific place to look and instead of looking there he comes back just two minutes later with "right the code for me."