Are you testing it on a real server (or a local server)? Is php running? You can check for php by creating a php file containing the single line
<?php phpinfo(); ?>
If it is simply a file on your home computer and you are double-clicking the file to open it, the php is unlikely to work, as it has to be processed server side.