Yeah, that's one way to do it. If you want (no real reason to, except security as anyone can access that IP log if they know/find the file name), you can use a MySQL database...if you want that, let me know
For redirecting, yes, your code is right, just add towards the bottom, after fclose($hFile); (next line) this:
header('Location: index.html');
note: change index.html to your page name.
Also, if you wanted, you can leave the extension as .PHP and make all pages your site as that--leaves for great expandability/lots more... Just make sure your links go to "index.php" instead of "index.html" etc.
Javascript is not necessary as you are using PHP