Code Snipplet Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Code Snipplet Help

Post 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
Last edited by John Cartwright on Tue Dec 23, 2003 2:21 am, edited 1 time in total.
User avatar
aquila125
Forum Commoner
Posts: 96
Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium

Post by aquila125 »

take a look at header() and instead of outputting html, output the file (read_file_contents)..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

You might wash his car too, and maybe walk his dog.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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?
Last edited by John Cartwright on Wed Dec 08, 2004 9:07 pm, edited 1 time in total.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
Last edited by John Cartwright on Sun Jun 13, 2004 7:38 pm, edited 1 time in total.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

that ended pretty abrubtly
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

lol

he'll be missed :roll:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

affirmative
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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."
Post Reply