javascript - how to pass number of hits count based on button action in php -


we developing web sit. have button.in button action placed pdf file downloading.working fine.but need how count download pdf file website.

we tried not get.

<?php //$down=$_get['down']; $a="hello"; $i=0; ?> <script type="text/javascript">     var i=0;     function submitform()     {         <?php         $i = @file_get_contents('count.txt'); // read hit count file         echo $i; //  display hit count         $i++; // increment hit count 1         @file_put_contents('count.txt', $i); // store new hit count         ?>       } </script> <html> <head> </head>  <body>     <input type="button" onclick="submitform()" value="submit 1" /> </body> </html> 

we got nothing .we new php please guide us.

well, can download pdf , count @ form submit:

<?php $i=0; $i = (int) @file_get_contents('count.txt'); // read hit count file if(!empty($_post)) {     $i++; // increment hit count 1     @file_put_contents('count.txt', $i); // store new hit count     // download     $file = 'filename.pdf';     header('content-description: file transfer');     header('content-type: application/pdf');     header('content-disposition: attachment; filename='.basename($file));     header('content-transfer-encoding: binary');     header('expires: 0');     header('cache-control: must-revalidate');     header('pragma: public');     header('content-length: ' . filesize($file)); } 

now use echo $i; want display number of downloads.

in html form should be:

<form method="post" action="">     <input type="submit" name="download" value="download"> </form> 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -