Like / Like Button

3

I want to make a button on my site with a counter next to it and I would like every time the counter to increase by 1 number. But I wanted to save that number of clicks on a file .txt on the server, and that everyone could click and see that counter.

A Like button, which could only be clicked once per computer. Do you understand? I want users to rate the content on my site with this button.

    
asked by anonymous 10.06.2015 / 21:52

1 answer

5

Three files will be used:

1 - main.php, which will display the download link and the number of downloads

2 - download_arquivo.php - This will increase the counter by 1, will download the file and redirect to main.php

3 - counter_file.txt - It will store the number of downloads

FILE 1 - MAIN.PHP:

<html>
<body>

<a href="download_arquivo">DOWNLOAD AQUI</a>
<br>N. de Downloads: <? include "contador_arquivo.txt"; ?>

</body>
</html>

ARCHIVE 2 - DOWNLOAD_ARQUIVO.PHP

<html>
<body>
<a href="java script:history.back(-1)">">Voltar</a>
<?php
//Abre o contador de downloads e acrescenrta em 1
$fp = fopen("contador_arquivo.txt","r");
$visitas = fgets($fp,255);
$visitas++;
fclose($fp);
$fp = fopen("contador_arquivo.txt","w+");
fwrite($fp, $visitas);
fclose($fp);
?>
<script language="JavaScript">
//Redireciona para o arquivo de download
location.href="SEU_ARQUIVO.ZIP";
</script>

FILE 3 - ARCHIVER.TXT

(escreva o numero 0 e salve o arquivo)

Source: Counter Clicks

    
10.06.2015 / 22:43