Code:
<?php
if(isset($_GET['aid'])) { $affiliateid = $_GET['aid']; }
?>
That way, if you hit your FHG with ?aid=123456 in the url, the php variable $affiliateid will be 123456 (or whatever that number is).
Then in your FHG page, where the join/enter/whatever links are. Link to them using
Code:
<a href="http://yoursystemurlhere.com?affiliatenumber=<?php print $affiliateid; ?>" title="">join now!</a>