Hi,
Since the failurl is - obviously - a parameter cPanel supports (sorry; didn't know), try typing it in concretely instead of abstractly. Try actually typing the URL your failurl should go to, and not the PHP version of it.
PHP Code:
<?php
echo "<input type=hidden name=failurl value=\"http://" ;
echo $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
echo "?failed=1\">";
?>
Becomes:
<?php
print "<input type='hidden' name='failurl' value='http://www.domain.com/URI?failed=1'>";
?>
By doing this, you can rule out if it's a problem with the actual PHP output. Just to see/debug. 
Just a thought,