What I can see is that the variable "link" contains both the href and the image itself.
<?php
ob_start();
session_start();
if(!isset($_SESSION['Username']))
{
$alt = 'Please Register';
$link = ( '<a href="http://www.test.com/signup.php"><img src=/images/register.png" alt="' .$alt. '" /></a>' );
echo $link;
}else{
$alt = 'Vote';
$link = ( '<a href="http://www.test.com/thanks.php"><img src=/images/vote.png" alt="' .$alt. '" /></a>' );
echo $link;
}
?>
Is that what you mean?