'; $name = htmlspecialchars($_GET["name"]); if (empty($name)) { echo 'If you would tell me your name then I will count your visits.
'; 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 $name . ' for your very first visit!'; } else { // Output the updated count. echo 'back ' . $name; echo " for visit # {$count}.\n"; } echo '
'; // Opens countlog.txt to change new hit number. $file = fopen( $path, 'w' ); fwrite( $file, $count ); fclose( $file ); } ?>