$response->redirect($GLOBALS['BASE_URL'] . '/reserve/'); }); //end new reservation respond('POST', '/success', function ($request, $response, $app) { //when the user has finally confirmed their reservation if (count($_SESSION['cts']['equipment']) <= 0) { //check to make sure that there is at least one equipment item selected $_SESSION['errors'][] = "Please select at least one item from the list of equipment."; $response->redirect($GLOBALS['BASE_URL'] . '/reserve/equipment'); } //put the data in the correct form before inserting it into the database $currtime = date('Y-n-j G:i:s'); $categories = ReserveDatabaseAPI::categories(); $start_time = date("H:i:s", strtotime($_SESSION['cts']['start_time'])); $end_time = date("H:i:s", strtotime($_SESSION['cts']['end_time'])); $start_date = date("Y-m-d", strtotime($_SESSION['cts']['start_date'])); $end_date = date("Y-m-d", strtotime($_SESSION['cts']['end_date'])); foreach ($_SESSION['cts']['equipment'] as $i) { $name = $categories[$i]; $equipment .= $name . ", "; } $data = array($_SESSION['wp_id'], $_SESSION['cts']['last_name'], $_SESSION['cts']['first_name'], $_SESSION['cts']['phone'], $_SESSION['cts']['email'], $currtime, $start_date, $start_time, $end_date, $end_time, $_SESSION['cts']['comments'], $_SESSION['cts']['location'], $_SESSION['cts']['room'], $_SESSION['cts']['title'], $_SESSION['cts']['reserve_type'], $equipment, "pending"); $insert_id = ReserveDatabaseAPI::insert_reservation($data); //mail the user and the cts staff CTSEmailAPI::email_user($_SESSION['cts']); CTSEmailAPI::email_CTS($_SESSION['cts'], $insert_id); unset($_SESSION['cts']); //delete the cts session array $app->tpl->display('success.tpl'); }); //end success