if it is calling itself then the first time the form is loaded there will be no domain to get, and you just want to display the form.
So check for a domain
<?php
if (isset($GET["domain"])) {
$url = "http://www." . $GET["domain"] . "/stats";
header("location: $url");
exit();
}
?>
Put this code right at the top of your file, as shown in my last post, before <html>
If a domain has been sent, it will redirect. If no domain, your page with form displays.