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!
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!
Last edited by John Cartwright on Tue Dec 23, 2003 2:21 am, edited 1 time in total.
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.
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.
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."