require("common.inc.php"); if($_POST['action']=="new") { $q=mysql_query("SELECT email,num,id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']); if(mysql_num_rows($q)) { $r=mysql_fetch_object($q); $_SESSION['registration_number']=$r->num; $_SESSION['registration_id']=$r->id; mysql_query("INSERT INTO students (registrations_id,email,year) VALUES ('$r->id','".mysql_escape_string($_SESSION['email'])."','".$config['FAIRYEAR']."')"); echo mysql_error(); mysql_query("UPDATE registrations SET status='open' WHERE id='$r->id'"); echo mysql_error(); header("Location: register_participants_main.php"); exit; } else { send_header("Participant Registration"); echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email']))); $_POST['action']="login"; } } else if($_POST['action']=="continue") { $q=mysql_query("SELECT registrations.id AS regid, registrations.num AS regnum, students.id AS studentid, students.name FROM registrations,students ". "WHERE students.email='".$_SESSION['email']."' ". "AND registrations.num='".$_POST['regnum']."' ". "AND students.registrations_id=registrations.id ". "AND registrations.year=".$config['FAIRYEAR']." ". "AND students.year=".$config['FAIRYEAR']); if(mysql_num_rows($q)) { $r=mysql_fetch_object($q); $_SESSION['registration_number']=$r->regnum; $_SESSION['registration_id']=$r->regid; header("Location: register_participants_main.php"); exit; } } //if they've alreayd logged in, and somehow wound back up here, take them back to where they should be if($_SESSION['registration_number'] && $_SESSION['registration_id'] && $_SESSION['email']) { header("Location: register_participants_main.php"); } send_header("Participant Registration"); if($_POST['action']=="login" && ( $_POST['email'] || $_SESSION['email']) ) { if($_POST['email']) $_SESSION['email']=$_POST['email']; echo "
"; } else { echo i18n("Please enter your email address to :"); echo "