process-child-form

[insert_php]
global $wpdb;

$email = mysql_escape_string($_POST[’email’]);

if($email == “”) die();
$tshirt=””;

$i=0;
$sports=0;
while($i<30) { $sports+= ($_POST['sport'.$i])*pow(3,$i); $i++; } $i=0; $societies=0; while($i<30) { $societies+= ($_POST['societies'.$i])*pow(3,$i); $i++; } $i=0; $music=0; while($i<30) { $music+= ($_POST['music'.$i])*pow(3,$i); $i++; } $i=0; $spareTime=0; while($i<30) { $spareTime+= ($_POST['spareTime'.$i])*pow(3,$i); $i++; } $other_sport = mysql_escape_string($_POST['other_sport']); $out = ""; $gapyear = ""; $international = mysql_escape_string($_POST['international']); $country = mysql_escape_string($_POST['country']); $blurb = mysql_escape_string($_POST['blurb']); $subject = mysql_escape_string($_POST['subject']); $name = mysql_escape_string($_POST['person']); $query2 = $wpdb->get_var(“SELECT COUNT(*) FROM `j_children` WHERE email=’$email'”);
if($query2 ==0) {
$query=”INSERT INTO `j_children` (`id` ,`parent_marriage` ,`email` ,`sports`, `other_sport`, `societies`, `music` ,`hobbies_social`,`out` ,`gapyear` ,”.
“`international` ,`country` ,`blurb` ,`subject` ,`name`) VALUES (“.
“NULL , 0, ‘$email’, ‘$sports’, ‘$other_sport’, ‘$societies’, ‘$music’, ‘$spareTime’, ‘$out’, ‘$gapyear’, ‘$international’,”.
” ‘$country’, ‘$blurb’, ‘$subject’, ‘$name’)”;

$wpdb->query($query);
}

header(“Location: http://mcr.chu.cam.ac.uk/child-form-done/”);

[/insert_php]