My php script is supposed to download a .zip file, and increment a counter. In the code below, the parameters passed in on the URL are not being recognized, so the line to download a file doesn't do anything, and if the file download doesn't work, the count loops endlessly, incrementing the count. My provider is using PHP V5.2.
I'd like for the passed parms to work, but I can live with hardcoding "myapp.zip" in the tag.
I need to return to the page that called count.php after it's work is done.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
//$Down=$_GET['Down'];
$Down=$_Post['Down'];
echo "File:" . $Down;?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<!--meta http-equiv="refresh" content="0;url=<?php echo $Down;?>"/-->
<meta http-equiv="refresh" content="0;url=MyApp.zip"/>
</head>
<body>
<?php
$filePath = 'count.txt';
// If file exists, read current count from it, otherwise, initialize it to 0
$count = file_exists($filePath) ? file_get_contents($filePath) : 0;
// Increment the count and overwrite the file, writing the new value<br />
file_put_contents($filePath, ++$count);
// Display current download count
//echo "Downloads:" . $count;
//header("Location: $r.htm");
?>
</body>
</html>
It's called from r.htm like this:
<form method="post" action="count.php?Down=myapp.zip" style="text-align: center">
<input type="submit" value="Download MyApp">
</form>