$name = strip_tags($_POST["categoryname"], '<b><i><u>'); $explanatory_text = strip_tags($_POST["explanatory"], '<a><b><i><u>'); if (is_null($_POST["dayid"]) or $_POST["dayid"] == 0) { $day_id = null; } else { $day_id = $_POST["dayid"]; } $cat_id = Database::add_category($name, $explanatory_text, null, $day_id); /* Step 2. Add the clues */ $clue_ids = array(); $multiplier = $_POST["point_scheme"] == "second" ? 3 : 2; for ($i = 1; $i <= 5; $i++) { $clue_text = strip_tags($_POST["clue{$i}"], '<a><b><i><u><img><br>'); $point_value = $multiplier * $i; $wrong_point_value = -$i; $clue_ids[$i] = Database::add_clue($clue_text, $cat_id, $point_value, $wrong_point_value); } /* Step 3. Add the responses */ for ($i = 1; $i <= 5; $i++) { if (is_null($_POST["response{$i}"])) { continue; } $raw_response = $_POST["response{$i}"]; if (!trim($raw_response)) { continue; } $responses = explode("\n", $_POST["response{$i}"]); foreach ($responses as $response) { $trimmed_response = trim($response); $correct = 1; Database::add_response($clue_ids[$i], $trimmed_response, $correct);