Hello, i need a little help...
This is not really for a page counter but for a simple rating system,
this php page saves the number of votes to a txt file and to another txt file the total score, each vote has a value from 1 to 5.
I want the PHP script to test the ip of user before it saves this values into the txt files so i think i need the IP`s to be saved to a txt file and alwais before voting the script tests to see if the ip has already been saved to that txt file so that each visitor can vote only once.
Here is my script now, what should I add ? :
<?php
//this is the same code we used in average.php to get the values of votes and score
$filename = 'votes.txt';
$fp = fopen($filename, "r");
$votes = fread($fp, filesize($filename));
fclose($fp);
$filename = 'score.txt';
$fp = fopen($filename, "r");
$score = fread($fp, filesize($filename));
fclose($fp);
//Up votes by one and add the user's choice to the score
$votes++;
$score = $score + $choice;
$filename = 'votes.txt';
$fp = fopen($filename, "w");
fwrite($fp, "$votes");
fclose($fp);
$filename = 'score.txt';
$fp = fopen($filename, "w");
fwrite($fp, "$score");
fclose($fp);
?>
So can anyone tell me what to add in code so script tests the ip of user ?
Thank you.