2004-12-02 19:40:43 +00:00
< ?
require ( " common.inc.php " );
2004-12-08 20:34:02 +00:00
include " register_participants.inc.php " ;
2004-12-02 19:40:43 +00:00
//authenticate based on email address and registration number from the SESSION
if ( ! $_SESSION [ 'email' ])
{
header ( " Location: register_participants.php " );
exit ;
}
2004-12-02 23:15:42 +00:00
if ( ! ( $_SESSION [ 'registration_number' ] && $_SESSION [ 'registration_id' ]))
2004-12-02 19:40:43 +00:00
{
header ( " Location: register_participants.php " );
exit ;
}
2004-12-03 04:28:18 +00:00
$q = mysql_query ( " SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students " .
2004-12-02 19:40:43 +00:00
" WHERE students.email=' " . $_SESSION [ 'email' ] . " ' " .
" AND registrations.num=' " . $_SESSION [ 'registration_number' ] . " ' " .
" AND registrations.id=' " . $_SESSION [ 'registration_id' ] . " ' " .
" AND students.registrations_id=registrations.id " .
" AND registrations.year= " . $config [ 'FAIRYEAR' ] . " " .
" AND students.year= " . $config [ 'FAIRYEAR' ]);
echo mysql_error ();
if ( mysql_num_rows ( $q ) == 0 )
{
header ( " Location: register_participants.php " );
exit ;
}
$r = mysql_fetch_object ( $q );
send_header ( " Participant Registration - Student Information " );
2004-12-02 23:15:42 +00:00
echo " <a href= \" register_participants_main.php \" ><< " . i18n ( " Back to Participant Registration Summary " ) . " </a><br /> " ;
echo " <br /> " ;
2004-12-02 19:40:43 +00:00
2004-12-03 15:38:37 +00:00
//now do any data saves
if ( $_POST [ 'action' ] == " save " )
{
$x = 1 ;
while ( $_POST [ " num " ][ $x ])
{
if ( $_POST [ 'id' ][ $x ] == 0 )
{
//INSERT new record
$dob = $_POST [ 'year' ][ $x ] . " - " . $_POST [ 'month' ][ $x ] . " - " . $_POST [ 'day' ][ $x ];
2005-01-05 14:32:24 +00:00
mysql_query ( " INSERT INTO students (registrations_id,firstname,lastname,email,address,city,province,postalcode,phone,dateofbirth,grade,schools_id,tshirt,medicalalert,foodreq,teachername,teacheremail,year) VALUES ( " .
2004-12-03 15:38:37 +00:00
" ' " . $_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 ])) . " ', " .
2004-12-08 20:18:36 +00:00
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'schools_id' ][ $x ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'tshirt' ][ $x ])) . " ', " .
2005-01-05 14:32:24 +00:00
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'medicalalert' ][ $x ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'foodreq' ][ $x ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'teachername' ][ $x ])) . " ', " .
" ' " . mysql_escape_string ( stripslashes ( $_POST [ 'teacheremail' ][ $x ])) . " ', " .
2004-12-03 15:38:37 +00:00
" ' " . $config [ 'FAIRYEAR' ] . " ') " );
echo mysql_error ();
echo notice ( i18n ( " %1 %2 successfully added " , array ( $_POST [ 'firstname' ][ $x ], $_POST [ 'lastname' ][ $x ])));
}
else
{
//UPDATE existing record
$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 ', " .
2004-12-08 20:18:36 +00:00
" grade=' " . mysql_escape_string ( stripslashes ( $_POST [ 'grade' ][ $x ])) . " ', " .
" schools_id=' " . mysql_escape_string ( stripslashes ( $_POST [ 'schools_id' ][ $x ])) . " ', " .
2005-01-05 14:32:24 +00:00
" medicalalert=' " . mysql_escape_string ( stripslashes ( $_POST [ 'medicalalert' ][ $x ])) . " ', " .
" foodreq=' " . mysql_escape_string ( stripslashes ( $_POST [ 'foodreq' ][ $x ])) . " ', " .
" teachername=' " . mysql_escape_string ( stripslashes ( $_POST [ 'teachername' ][ $x ])) . " ', " .
" teacheremail=' " . mysql_escape_string ( stripslashes ( $_POST [ 'teacheremail' ][ $x ])) . " ', " .
2004-12-08 20:18:36 +00:00
" tshirt=' " . mysql_escape_string ( stripslashes ( $_POST [ 'tshirt' ][ $x ])) . " ' " .
2004-12-03 15:38:37 +00:00
" WHERE id=' " . $_POST [ 'id' ][ $x ] . " ' " );
echo notice ( i18n ( " %1 %2 successfully updated " , array ( $_POST [ 'firstname' ][ $x ], $_POST [ 'lastname' ][ $x ])));
}
$x ++ ;
}
2004-12-08 20:34:02 +00:00
2004-12-06 21:37:49 +00:00
}
2004-12-03 15:38:37 +00:00
2004-12-06 21:37:49 +00:00
if ( $_GET [ 'action' ] == " removestudent " )
{
//first make sure this is one belonging to this registration id
$q = mysql_query ( " SELECT id FROM students WHERE id=' " . $_GET [ 'removestudent' ] . " ' AND registrations_id=' " . $_SESSION [ 'registration_id' ] . " ' " );
if ( mysql_num_rows ( $q ) == 1 )
{
mysql_query ( " DELETE FROM students WHERE id=' " . $_GET [ 'removestudent' ] . " ' AND registrations_id=' " . $_SESSION [ 'registration_id' ] . " ' " );
echo notice ( i18n ( " Student successfully removed " ));
}
else
{
echo error ( i18n ( " Invalid student to remove " ));
}
2004-12-03 15:38:37 +00:00
}
2004-12-08 20:34:02 +00:00
//output the current status
$newstatus = studentStatus ();
if ( $newstatus != " complete " )
{
echo error ( i18n ( " Student Information Incomplete " ));
}
else if ( $newstatus == " complete " )
{
echo happy ( i18n ( " Student Information Complete " ));
}
2004-12-03 15:38:37 +00:00
//now query and display
2004-12-02 23:15:42 +00:00
$q = mysql_query ( " SELECT * FROM students WHERE registrations_id=' " . $_SESSION [ 'registration_id' ] . " ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' " );
if ( mysql_num_rows ( $q ) == 0 )
{
//uhh oh, we didnt find any, this isnt possible! lets insert one using the logged in persons email address
//although... this can never really happen, since the above queries only allow the page to view if the student
//is found in the students table... soo... well, lets leave it here as a fallback anyways, just incase
mysql_query ( " INSERT INTO students (registrations_id,email,year) VALUES (' " . $_SESSION [ 'registration_id' ] . " ',' " . mysql_escape_string ( $_SESSION [ 'email' ]) . " ',' " . $config [ 'FAIRYEAR' ] . " ') " );
2004-12-03 00:11:09 +00:00
//if we just inserted it, then we will obviously find 1
$numfound = 1 ;
2004-12-02 23:15:42 +00:00
}
2004-12-03 00:11:09 +00:00
else
2004-12-02 23:15:42 +00:00
{
2004-12-03 00:11:09 +00:00
$numfound = mysql_num_rows ( $q );
2004-12-02 23:15:42 +00:00
}
2004-12-03 15:38:37 +00:00
if ( $_GET [ 'numstudents' ])
$numtoshow = $_GET [ 'numstudents' ];
else
$numtoshow = $numfound ;
2004-12-03 00:11:09 +00:00
echo " <form name= \" numstudentsform \" method= \" get \" action= \" register_participants_students.php \" > " ;
echo i18n ( " Number of students that worked on the project: " );
echo " <select name= \" numstudents \" onchange= \" document.forms.numstudentsform.submit() \" > \n " ;
for ( $x = $config [ 'minstudentsperproject' ]; $x <= $config [ 'maxstudentsperproject' ]; $x ++ )
2004-12-02 23:15:42 +00:00
{
2004-12-06 21:37:49 +00:00
if ( $x < $numfound )
continue ;
2004-12-03 15:38:37 +00:00
if ( $numtoshow == $x ) $selected = " selected= \" selected \" " ; else $selected = " " ;
2004-12-02 23:15:42 +00:00
2004-12-03 00:11:09 +00:00
echo " <option $selected value= \" $x\ " > $x </ option > \n " ;
}
echo " </select> " ;
2004-12-02 23:15:42 +00:00
echo " </form> " ;
2004-12-03 15:38:37 +00:00
echo " <form name= \" studentdata \" method= \" post \" action= \" register_participants_students.php \" > " ;
2004-12-07 15:31:49 +00:00
echo " <input type= \" hidden \" name= \" action \" value= \" save \" /> " ;
2004-12-03 00:11:09 +00:00
for ( $x = 1 ; $x <= $numtoshow ; $x ++ )
2004-12-02 23:15:42 +00:00
{
$studentinfo = mysql_fetch_object ( $q );
2004-12-03 00:11:09 +00:00
echo " <h3> " . i18n ( " Student %1 Details " , array ( $x )) . " </h3> " ;
2004-12-03 15:38:37 +00:00
//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.
2004-12-07 15:31:49 +00:00
echo " <input type= \" hidden \" name= \" num[ $x ] \" value= \" true \" /> " ;
2004-12-03 15:38:37 +00:00
//save the ID, or 0 if it doesnt exist
2004-12-07 15:31:49 +00:00
echo " <input type= \" hidden \" name= \" id[ $x ] \" value= \" $id\ " /> " ;
2004-12-03 00:11:09 +00:00
echo " <table> " ;
2004-12-03 04:28:18 +00:00
echo " <tr> \n " ;
2004-12-07 15:31:49 +00:00
echo " <td> " . i18n ( " First Name " ) . " </td><td><input type= \" text \" name= \" firstname[ $x ] \" value= \" $studentinfo->firstname\ " /></ td > \n " ;
echo " <td> " . i18n ( " Last Name " ) . " </td><td><input type= \" text \" name= \" lastname[ $x ] \" value= \" $studentinfo->lastname\ " /></ td > \n " ;
2004-12-03 15:38:37 +00:00
echo " </tr> \n " ;
echo " <tr> \n " ;
2004-12-07 15:31:49 +00:00
echo " <td> " . i18n ( " Email Address " ) . " </td><td><input type= \" text \" name= \" email[ $x ] \" value= \" $studentinfo->email\ " /></ td > \n " ;
2004-12-08 20:18:36 +00:00
echo " <td> " . i18n ( " City " ) . " </td><td><input type= \" text \" name= \" city[ $x ] \" value= \" $studentinfo->city\ " /></ td > \n " ;
2004-12-03 04:28:18 +00:00
echo " </tr> \n " ;
echo " <tr> \n " ;
2004-12-07 15:31:49 +00:00
echo " <td> " . i18n ( " Address " ) . " </td><td><input type= \" text \" name= \" address[ $x ] \" value= \" $studentinfo->address\ " /></ td > \n " ;
2004-12-08 20:18:36 +00:00
echo " <td> " . i18n ( " Province " ) . " </td><td><input type= \" text \" name= \" province[ $x ] \" value= \" $studentinfo->province\ " /></ td > \n " ;
2004-12-03 04:28:18 +00:00
echo " </tr> \n " ;
echo " <tr> \n " ;
2004-12-07 15:31:49 +00:00
echo " <td> " . i18n ( " Postal Code " ) . " </td><td><input type= \" text \" name= \" postalcode[ $x ] \" value= \" $studentinfo->postalcode\ " /></ td > \n " ;
echo " <td> " . i18n ( " Phone " ) . " </td><td><input type= \" text \" name= \" phone[ $x ] \" value= \" $studentinfo->phone\ " /></ td > \n " ;
2004-12-03 04:28:18 +00:00
echo " </tr> \n " ;
echo " <tr> \n " ;
echo " <td> " . i18n ( " Date of Birth " ) . " </td><td> \n " ;
list ( $year , $month , $day ) = split ( " - " , $studentinfo -> dateofbirth );
echo " <table><tr><td> " ;
2004-12-03 15:38:37 +00:00
emit_day_selector ( " day[ $x ] " , $day );
2004-12-03 04:28:18 +00:00
echo " </td><td> \n " ;
2004-12-03 15:38:37 +00:00
emit_month_selector ( " month[ $x ] " , $month );
2004-12-03 04:28:18 +00:00
echo " </td><td> \n " ;
2004-12-03 15:38:37 +00:00
emit_year_selector ( " year[ $x ] " , $year , date ( " Y " ) - 19 , date ( " Y " ) - 10 );
2004-12-03 04:28:18 +00:00
echo " </td></tr></table> \n " ;
echo " </td> \n " ;
echo " <td> " . i18n ( " Grade " ) . " </td><td> \n " ;
2004-12-03 15:38:37 +00:00
echo " <select name= \" grade[ $x ] \" > \n " ;
2004-12-07 05:33:26 +00:00
echo " <option value= \" \" > " . i18n ( " Grade " ) . " </option> \n " ;
2004-12-03 04:28:18 +00:00
for ( $gr = $config [ 'mingrade' ]; $gr <= $config [ 'maxgrade' ]; $gr ++ )
{
2004-12-03 15:38:37 +00:00
if ( $studentinfo -> grade == $gr ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" $gr\ " > $gr </ option > \n " ;
2004-12-03 04:28:18 +00:00
}
echo " </select> \n " ;
echo " </td> " ;
echo " </tr> " ;
2005-01-05 14:32:24 +00:00
echo " <tr> \n " ;
echo " <td> " . i18n ( " Medical Alert Info " ) . " </td><td colspan= \" 3 \" > " ;
echo " <input name= \" medicalalert \" type= \" text \" size= \" 50 \" value= \" $studentinfo->medicalalert\ " /> " ;
echo " </td> " ;
echo " </tr> \n " ;
if ( $config [ 'participant_student_foodreq' ] == " yes " )
{
echo " <tr> \n " ;
echo " <td> " . i18n ( " Special Food Requirements " ) . " </td><td colspan= \" 3 \" > " ;
echo " <input name= \" foodreq \" type= \" text \" size= \" 50 \" value= \" $studentinfo->foodreq\ " /> " ;
echo " </td> " ;
echo " </tr> \n " ;
}
2004-12-08 20:18:36 +00:00
echo " <tr> \n " ;
echo " <td> " . i18n ( " School " ) . " </td><td> " ;
2004-12-08 20:34:02 +00:00
$schoolq = mysql_query ( " SELECT id,school FROM schools WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER by school " );
2004-12-08 20:18:36 +00:00
echo " <select name= \" schools_id[ $x ] \" > \n " ;
echo " <option value= \" \" > " . i18n ( " Choose School " ) . " </option> \n " ;
2004-12-08 20:34:02 +00:00
while ( $r = mysql_fetch_object ( $schoolq ))
2004-12-08 20:18:36 +00:00
{
if ( $studentinfo -> schools_id == $r -> id ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" $r->id\ " > " .htmlspecialchars( $r->school ). " </ option > \n " ;
2004-12-03 04:28:18 +00:00
2004-12-08 20:18:36 +00:00
}
echo " </select> " ;
echo " </td> \n " ;
echo " <td> " . i18n ( " T-Shirt Size " ) . " </td><td> " ;
echo " <select name= \" tshirt[ $x ] \" > \n " ;
if ( $studentinfo -> tshirt == " small " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" small \" > " . i18n ( " Small " ) . " </option> " ;
if ( $studentinfo -> tshirt == " medium " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" medium \" > " . i18n ( " Medium " ) . " </option> " ;
if ( $studentinfo -> tshirt == " large " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" large \" > " . i18n ( " Large " ) . " </option> " ;
if ( $studentinfo -> tshirt == " xlarge " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" xlarge \" > " . i18n ( " X-Large " ) . " </option> " ;
echo " </select> " ;
echo " </td> \n " ;
echo " </tr> \n " ;
2004-12-03 04:28:18 +00:00
2005-01-05 14:32:24 +00:00
echo " <tr> \n " ;
echo " <td> " . i18n ( " Teacher Name " ) . " </td><td><input type= \" text \" name= \" teachername[ $x ] \" value= \" $studentinfo->teachername\ " /></ td > \n " ;
echo " <td> " . i18n ( " Teacher Email " ) . " </td><td><input type= \" text \" name= \" teacheremail[ $x ] \" value= \" $studentinfo->teacheremail\ " /></ td > \n " ;
echo " </tr> \n " ;
2004-12-03 00:11:09 +00:00
echo " </table> " ;
2004-12-08 20:18:36 +00:00
2004-12-07 05:33:26 +00:00
if ( $numfound > $config [ 'minstudentsperproject' ] && $studentinfo -> id )
2004-12-06 21:37:49 +00:00
{
echo " <div align= \" right \" ><a onclick= \" return confirmClick(' " . i18n ( " Are you sure you want to remove this student from the project? " ) . " '); \" class= \" caution \" href= \" register_participants_students.php?action=removestudent&removestudent= $studentinfo->id\ " > " .i18n( " Remove this student from project " ). " </ a ></ div > " ;
}
2004-12-03 00:11:09 +00:00
echo " <br /> " ;
echo " <br /> " ;
2004-12-02 23:15:42 +00:00
}
2004-12-07 15:31:49 +00:00
echo " <input type= \" submit \" value= \" " . i18n ( " Save Student Information " ) . " \" /> \n " ;
2004-12-03 15:38:37 +00:00
echo " </form> " ;
2004-12-07 05:33:26 +00:00
echo " <br /> " ;
echo notice ( i18n ( " Note: if you change the email address that you are logged in with right now, you will be automatically logged out and will need to log back in again with your new email address " ));
2004-12-02 19:40:43 +00:00
send_footer ();
?>