';
$name = htmlspecialchars($_GET["name"]);
if (empty($name))
{
echo 'If you would tell me what kind of frog you are then I will cast your vote.
';
echo 'ie, after the url add [?name=myname].';
}
else
{
// Add correct path to your countlog.txt file.
$path = $name . '.txt';
// Opens countlog.txt to read the number of hits.
$file = fopen( $path, 'r' );
$count = fgets( $file, 1000 );
fclose( $file );
// Update the count.
$count = abs( intval( $count ) ) + 1;
echo 'Welcome ';
if ($count == 1)
{
echo 'This is the first time a [' . $name . '] frog came for a visit!';
}
else
{
// Output the updated count.
echo $name . ' frog!';
echo " You have {$count} votes.\n";
}
echo '
';
// Opens countlog.txt to change new hit number.
$file = fopen( $path, 'w' );
fwrite( $file, $count );
fclose( $file );
}
?>