$q=mysql_query("SELECT email,num,id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']);
mysql_query("INSERT INTO students (registrations_id,email,year) VALUES ('$r->id','".mysql_escape_string($_SESSION['email'])."','".$config['FAIRYEAR']."')");
mysql_query("UPDATE registrations SET status='open' WHERE id='$r->id'");
$q=mysql_query("SELECT registrations.id AS regid, registrations.num AS regnum, students.id AS studentid, students.firstname FROM registrations,students ".
$q=mysql_query("SELECT registrations.num FROM registrations, students WHERE students.email='".$_SESSION['email']."' AND students.registrations_id=registrations.id");
echoerror(i18n("Registration is closed. You can not create a new account"));
$showform=false;
echo"<A href=\"register_participants.php\">Back to Participant Registration Login Page</a>";
}
else
{
$regnum=0;
//now create the new registration record, and assign a random/unique registration number to then.
do
{
//random number between
//100000 and 999999 (six digit integer)
$regnum=rand(100000,999999);
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
}while(mysql_num_rows($q)>0);
//actually insert it
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
"'$regnum',".
"'".$_SESSION['email']."',".
"NOW(),".
"'new',".
$config['FAIRYEAR'].
")");
$mailbody="A new registration account has been created for you.\n".
"To access your registration account, please enter\n".
"enter the following registration number into the\n".
"registration website:\n".
"\n".
"Registration Number: $regnum\n".
"\n";
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
echoi18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']));
echoi18n("If you have lost or forgotten your <b>registration number</b>, please <a href=\"register_participants.php?action=resend\">click here to resend</a> it to your email address");
echonotice(i18n("Registration for the %1 %2 is now closed. Existing registrants can login and view (read only) their information, as well as apply for special awards (if applicable).",array($config['FAIRYEAR'],$config['fairname'])));
echoi18n("Please enter your email address to login");