forked from science-ation/science-ation
Fix a bug where the school id was not being set when participant registration type was set to invite or singlepassword
This commit is contained in:
parent
79fe64926c
commit
45b4f7b220
@ -1 +1,2 @@
|
||||
ALTER TABLE `judges` DROP `catpref`, DROP `divpref`;
|
||||
ALTER TABLE `registrations` ADD `schools_id` INT UNSIGNED DEFAULT NULL ;
|
||||
|
@ -29,13 +29,13 @@
|
||||
|
||||
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']);
|
||||
$q=mysql_query("SELECT email,num,id,schools_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']."')");
|
||||
mysql_query("INSERT INTO students (registrations_id,email,schools_id,year) VALUES ('$r->id','".mysql_escape_string($_SESSION['email'])."','".$r->schools_id."','".$config['FAIRYEAR']."')");
|
||||
mysql_query("UPDATE registrations SET status='open' WHERE id='$r->id'");
|
||||
|
||||
header("Location: register_participants_main.php");
|
||||
@ -245,6 +245,7 @@
|
||||
$allownew=true;
|
||||
$showform=true;
|
||||
$showschoolpasswordform=false;
|
||||
$schoolidquery="'".$_POST['schoolid']."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -320,12 +321,15 @@
|
||||
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
|
||||
}while(mysql_num_rows($q)>0);
|
||||
|
||||
if(!$schoolidquery) $schoolidquery="null";
|
||||
|
||||
//actually insert it
|
||||
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
|
||||
mysql_query("INSERT INTO registrations (num,email,start,status,schools_id,year) VALUES (".
|
||||
"'$regnum',".
|
||||
"'".$_SESSION['email']."',".
|
||||
"NOW(),".
|
||||
"'new',".
|
||||
$schoolidquery.",".
|
||||
$config['FAIRYEAR'].
|
||||
")");
|
||||
|
||||
|
@ -78,6 +78,19 @@ if($_POST['action']=="save")
|
||||
{
|
||||
if($_POST['id'][$x]==0)
|
||||
{
|
||||
//if they use schoolpassword or singlepassword, then we need to set the school based on the school stored in the registration record. for anything else they can school the school on their own.
|
||||
if($config['participant_registration_type']=="schoolpassword" || $config['participant_registration_type']=="invite")
|
||||
{
|
||||
$q=mysql_query("SELECT schools_id FROM registrations WHERE id='".$_SESSION['registration_id']."' AND YEAR='".$config['FAIRYEAR']."'");
|
||||
$r=mysql_fetch_object($q);
|
||||
$schools_id=$r->schools_id;
|
||||
|
||||
$schoolvalue="'$schools_id', ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$schoolvalue="'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ";
|
||||
}
|
||||
//INSERT new record
|
||||
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x];
|
||||
mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,email,address,city,province,postalcode,phone,dateofbirth,grade,schools_id,tshirt,medicalalert,foodreq,teachername,teacheremail,year) VALUES (".
|
||||
@ -93,7 +106,7 @@ if($_POST['action']=="save")
|
||||
"'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
|
||||
"'$dob', ".
|
||||
"'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
|
||||
"'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ".
|
||||
$schoolvalue.
|
||||
"'".mysql_escape_string(stripslashes($_POST['tshirt'][$x]))."', ".
|
||||
"'".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ".
|
||||
"'".mysql_escape_string(stripslashes($_POST['foodreq'][$x]))."', ".
|
||||
@ -106,6 +119,18 @@ if($_POST['action']=="save")
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//if they use schoolpassword or singlepassword, then we dont need to save teh schools_id because its already set when they inserted the record, and we dont allow them to change their school.
|
||||
if($config['participant_registration_type']=="schoolpassword" || $config['participant_registration_type']=="invite")
|
||||
{
|
||||
$schoolquery="";
|
||||
}
|
||||
else
|
||||
{
|
||||
$schoolquery="schools_id='".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ";
|
||||
}
|
||||
|
||||
|
||||
//UPDATE existing record
|
||||
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x];
|
||||
mysql_query("UPDATE students SET ".
|
||||
@ -120,7 +145,7 @@ if($_POST['action']=="save")
|
||||
"phone='".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
|
||||
"dateofbirth='$dob', ".
|
||||
"grade='".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
|
||||
"schools_id='".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ".
|
||||
$schoolquery.
|
||||
"medicalalert='".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ".
|
||||
"foodreq='".mysql_escape_string(stripslashes($_POST['foodreq'][$x]))."', ".
|
||||
"teachername='".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
|
||||
|
Loading…
x
Reference in New Issue
Block a user