diff --git a/TODO b/TODO new file mode 100644 index 0000000..2f4ea74 --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +- Fix sending of registration number to email addresses other than the first. diff --git a/register_participants.inc.php b/register_participants.inc.php index a2853b8..9fdbb07 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -2,7 +2,7 @@ function studentStatus() { global $config; - $required_fields=array("firstname","lastname","address","city","postalcode","phone","email","grade","age"); + $required_fields=array("firstname","lastname","address","city","postalcode","phone","email","grade"); $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); @@ -10,7 +10,7 @@ function studentStatus() { foreach ($required_fields AS $req) { - if(!$r->$req || $r->$req==0) + if(!$r->$req) { return "incomplete"; } diff --git a/register_participants_students.php b/register_participants_students.php index c3d9c80..d90fd8c 100644 --- a/register_participants_students.php +++ b/register_participants_students.php @@ -34,6 +34,75 @@ echo mysql_error(); echo "<< ".i18n("Back to Participant Registration Summary")."
"; echo "
"; + +//now do any data saves + +if($_POST['action']=="save") +{ + $x=1; + while($_POST["num"][$x]) + { + //FIXME: move required field checking up here + if($_POST['id'][$x]==0) + { + //INSERT new record + //FIXME: check for required fields before allowing INSERT + $dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x]; + mysql_query("INSERT INTO students (registrations_id,firstname,lastname,email,address,city,province,postalcode,phone,dateofbirth,grade,year) VALUES (". + "'".$_SESSION['registration_id']."', ". + "'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['address'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ". + "'$dob', ". + "'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ". + "'".$config['FAIRYEAR']."')"); +echo mysql_error(); + + echo notice(i18n("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x]))); + + } + else + { + //UPDATE existing record + //FIXME: check for required fields before allowing UPDATE + $dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x]; + mysql_query("UPDATE students SET ". + "firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ". + "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". + "email='".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ". + "address='".mysql_escape_string(stripslashes($_POST['address'][$x]))."', ". + "city='".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ". + "province='".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ". + "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ". + "phone='".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ". + "dateofbirth='$dob', ". + "grade='".mysql_escape_string(stripslashes($_POST['grade'][$x]))."' ". + "WHERE id='".$_POST['id'][$x]."'"); + echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x]))); + + } + $x++; + } + + + + + + + + + + +} + + +//now query and display + $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); if(mysql_num_rows($q)==0) @@ -50,59 +119,78 @@ echo mysql_error(); $numfound=mysql_num_rows($q); } + if($_GET['numstudents']) + $numtoshow=$_GET['numstudents']; + else + $numtoshow=$numfound; + + echo "
"; echo i18n("Number of students that worked on the project: "); echo ""; echo "
"; - if($_GET['numstudents']) - $numtoshow=$_GET['numstudents']; - else - $numtoshow=$numfound; - + echo "
"; + echo ""; for($x=1;$x<=$numtoshow;$x++) { $studentinfo=mysql_fetch_object($q); echo "

".i18n("Student %1 Details",array($x))."

"; + + //if we have a valid student, set their ID, so we can UPDATE when we submit + //if there is no record for this student, then set the ID to 0, so we will INSERT when we submit + if($studentinfo->id) $id=$studentinfo->id; else $id=0; + + //true should work here, it just has to be set to _something_ for it to work. + echo ""; + + //save the ID, or 0 if it doesnt exist + echo ""; echo ""; echo "\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "
".i18n("First Name")."firstname\">".i18n("Last Name")."lastname\">".i18n("First Name")."firstname\">".i18n("Last Name")."lastname\">
".i18n("Address")."address\">".i18n("City")."city\">".i18n("Email Address")."email\">".i18n("Province")."province\">
".i18n("Postal Code")."postalcode\">".i18n("Phone")."phone\">".i18n("Address")."address\">".i18n("City")."city\">
".i18n("Postal Code")."postalcode\">".i18n("Phone")."phone\">
".i18n("Date of Birth")."\n"; list($year,$month,$day)=split("-",$studentinfo->dateofbirth); echo "
"; - emit_day_selector("day$x",$day); + emit_day_selector("day[$x]",$day); echo "\n"; - emit_month_selector("month$x",$month); + emit_month_selector("month[$x]",$month); echo "\n"; - emit_year_selector("year$x",$year,date("Y")-19,date("Y")-10); + emit_year_selector("year[$x]",$year,date("Y")-19,date("Y")-10); echo "
\n"; echo "
".i18n("Grade")."\n"; - echo "\n"; echo "\n"; for($gr=$config['mingrade'];$gr<=$config['maxgrade'];$gr++) { - echo "\n"; + if($studentinfo->grade==$gr) $sel="selected=\"selected\""; else $sel=""; + + echo "\n"; } echo "\n"; @@ -136,6 +224,8 @@ echo mysql_error(); echo "
"; echo "
"; } + echo "\n"; + echo ""; send_footer(); ?>