Correct, you are not allowed to use HTML in threads. See below under 'Posting Rules', for which code is allowed and which is not. Javascript, for obvious reasons, is not allowed because you can easily tweak javascript to be hacker-friendly.
Simply add it to a php file then call that php file using <?php include('filename.php'); ?> and it will included wherever you want it to be -- also meaning that the original file has to be somefilename.php