Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first code
- <?php
- $filename = 'click_count.txt';
- $handle = fopen($filename, 'r');
- $hits = trim(fgets($handle)) + 1;
- fclose($handle);
- $handle = fopen($filename, 'w');
- fwrite($handle, $hits);
- fclose($handle);
- // Uncomment the next line (remove //) to display the number of hits on your page.
- //echo $hits;
- ?>
- second code
- <?php
- $click_value = '0.001'; //Amount in dollars that each click is worth
- function increment_clicks()
- {
- //Get current click count
- $clicks = ((file_exists('click_count.txt')) ? file_get_contents('click_count.txt') : 0);
- //Add current click to count
- $clicks++;
- //Save new value to file
- $file = fopen('click_count.txt', 'w');
- fwrite($file, $clicks);
- fclose($file);
- }
- function get_click_amount()
- {
- global $click_value;
- //Get current click count
- $clicks = ((file_exists('click_count.txt')) ? file_get_contents('click_count.txt') : 0);
- //Return value of all clicks based on $click_value, formatted to 2 decimal places
- return number_format($clicks * $click_value, 3);
- }
- if (isset($_GET['sa']))
- {
- //Search button was clicked, increment count
- increment_clicks();
- }
- $click_amount = get_click_amount();
- ?>
- can someone tell me why when the amount goes from $1.999 then next one goes back to $1.000 not $2.000 thanks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement