2004-12-02 19:40:43 +00:00
< ?
require ( " common.inc.php " );
//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 ;
}
$q = mysql_query ( " SELECT registrations.id AS regid, students.id AS studentid, students.name FROM registrations,students " .
" 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-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 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-03 00:11:09 +00:00
if ( $_GET [ 'numstudents' ] == $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 00:11:09 +00:00
if ( $_GET [ 'numstudents' ])
$numtoshow = $_GET [ 'numstudents' ];
else
$numtoshow = $numfound ;
2004-12-02 23:15:42 +00:00
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> " ;
echo " <table> " ;
echo " <tr><td> " . i18n ( " Name " ) . " : </td><td><input type= \" text \" name= \" name $x\ " value = \ " $studentinfo->name\ " ></ td ></ tr > " ;
echo " </table> " ;
echo " <br /> " ;
echo " <br /> " ;
2004-12-02 23:15:42 +00:00
}
2004-12-02 19:40:43 +00:00
send_footer ();
?>