Unlocking FreeRange

"; print "
\n"; if ($_COOKIE["freerange_code1"]) { print "You have already unlocked Freerange!
"; if ($_POST["certificate"]) { print "Your certificate has not been used.
"; } print "
"; PrintInstructions($_COOKIE["freerange_code1"]); } else if (!$_POST["certificate"]) { ob_end_flush(); print "

Please enter certificate number





"; } else { $certificate = myAddSlashes($_POST["certificate"]); $dbh=mysql_connect ("localhost", "hugh_web", "webbywebbywonka") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("hugh_fundieware"); $result = mysql_query("SELECT * from frCertificate ". "WHERE code='$certificate'" ); if (!$result) { ob_end_flush(); print "Oops"; //.mysql_error(); } else { if ($row = mysql_fetch_assoc($result)) { $cid = $row['certificate_id']; $result = mysql_query("UPDATE frCertificate ". "SET used = used + 1 ". "WHERE code='$certificate' AND used < total" ); if (mysql_affected_rows() <> 1) { ob_end_flush(); print "Sorry, that certificate is no longer valid."; } else { // Create new user id ... $from_id = (int)$_POST["from"]; $ip = $_SERVER["REMOTE_ADDR"]; $result = mysql_query("INSERT INTO frUser ". "(contact_id,certificate_id,created,linked_from,ip) ". "VALUES(0,$cid,now(),$from_id,'$ip')"); if (!$result) { ob_end_flush(); print "Ooops, error creating entry. Sorry\n"; } else { $user_id = mysql_insert_id(); $expire = time() + 60*60*24*8; $year = date("Y",$expire) - 2006; $doy = (int)(date("z",$expire)); $code = exec("~/userid/UserID $user_id $year $doy"); $c1 = setcookie("freerange_uid",$user_id,0,"/"); $c2 = setcookie("freerange_code1","a$code",$expire,"/"); ob_end_flush(); if ($code) { mysql_query("UPDATE frUser SET code='$code' ". "WHERE user_id=$user_id"); print "You have successfully unlocked FreeRange !

"; PrintInstructions("a$code"); } else print "Could not create code ?"; } } } else { print "Sorry, that certificate is not valid."; print "

Back to the Buy Screen"; } } } print "
\n"; include("../footer.php"); ?>