require("common.inc.php");
include "register_participants.inc.php";
//authenticate based on email address and registration number from the SESSION
if(!$_SESSION['email'])
{
header("Location: register_participants.php");
exit;
}
if(!$_SESSION['registration_number'])
{
header("Location: register_participants.php");
exit;
}
$q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname 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;
}
$authinfo=mysql_fetch_object($q);
//send the header
send_header("Participant Registration - Safety Information");
echo "<< ".i18n("Back to Participant Registration Summary")."
";
echo "
";
if($_POST['action']=="save")
{
//first we will delete all their old answer, its easier to delete and re-insert in this case then it would be to find the corresponding answers and update them
mysql_query("DELETE FROM safety WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
$safetyids=array_keys($_POST['safety']);
foreach($safetyids AS $key=>$val)
{
mysql_query("INSERT INTO safety (registrations_id,safetyquestions_id,year,answer) VALUES (".
"'".$_SESSION['registration_id']."', ".
"'$val', ".
"'".$config['FAIRYEAR']."', ".
"'".mysql_escape_string(stripslashes($_POST['safety'][$val]))."')");
echo mysql_error();
}
}
//output the current status
$newstatus=safetyStatus();
if($newstatus!="complete")
{
echo error(i18n("Safety Information Incomplete"));
}
else if($newstatus=="complete")
{
echo happy(i18n("Safety Information Complete"));
}
echo "