In order to use PHP code within the Smarty templates, you either have to wrap the code in {php} {/php} tags, or use {include_php} if you are including a separate PHP file. Examples:
Inserting PHP code into a template:
{php}
// PHP code goes here
{/php}
Including a PHP file into a template:
{include_php file="my_php_file.php"}