10) exit('Bourbon setup file not found'); } require_once($bourbon_setup_file); // Loads Bourbon core object with config and request data, sets up $bourbon_page and $bourbon_session } $bourbon_timer->Record('starting page:', basename(__FILE__)); // END BOURBON LITE HEADER require_once(BOURBON_PATH . '/_bourbon/core/BourbonUtilities.php'); function format_minutes($minutes) { $minutes_word = (floor($minutes) == 1 ? 'minute' : 'minutes'); if ($minutes == floor($minutes)) return ($minutes . ' ' . $minutes_word); else return (floor($minutes) . ' ' . $minutes_word . ' ' . ceil(60*($minutes-floor($minutes))) . ' seconds'); } //$bourbon_db->show_queries = true; $form_id = (int) @$_SESSION['form_id']; $performance_id = (int) @$_REQUEST['performance_id']; // $action may be one of the following: list, add, add2, save, delete, delete_confirm $action = @$_REQUEST['action']; if (empty($action)) { $action = 'list'; } $error_message = array(); switch ($action) { case 'save_contact': if (empty($_SESSION['form_id'])) { // create session $phone = preg_replace('/[^0-9-]/', '', @$_REQUEST['phone']); $success = $bourbon_db->Query("INSERT INTO forms SET order_code = '" . $bourbon->request['code'] . "', contest_year = '" . $bourbon->config['contest_year'] . "', first_name = '" . $bourbon_db->EscapeString($_REQUEST['first_name']) . "', last_name = '" . $bourbon_db->EscapeString($_REQUEST['last_name']) . "', address1 = '" . $bourbon_db->EscapeString($_REQUEST['address1']) . "', address2 = '" . $bourbon_db->EscapeString($_REQUEST['address2']) . "', city = '" . $bourbon_db->EscapeString($_REQUEST['city']) . "', state = '" . $bourbon_db->EscapeString($_REQUEST['state']) . "', zip = '" . $bourbon_db->EscapeString($_REQUEST['zip']) . "', phone = '" . $bourbon_db->EscapeString($phone) . "', email = '" . $bourbon_db->EscapeString($_REQUEST['email']) . "', date = '" . $bourbon->request['timestamp'] . "'"); $_SESSION['form_id'] = $form_id = $bourbon_db->InsertId(); $_SESSION['phone'] = $phone; } else { $success = $bourbon_db->Query("UPDATE forms SET name = '" . $bourbon_db->EscapeString($_REQUEST['name']) . "', address1 = '" . $bourbon_db->EscapeString($_REQUEST['address1']) . "', address2 = '" . $bourbon_db->EscapeString($_REQUEST['address2']) . "', city = '" . $bourbon_db->EscapeString($_REQUEST['city']) . "', state = '" . $bourbon_db->EscapeString($_REQUEST['state']) . "', zip = '" . $bourbon_db->EscapeString($_REQUEST['zip']) . "', phone = '" . $bourbon_db->EscapeString($_REQUEST['phone']) . "', email = '" . $bourbon_db->EscapeString($_REQUEST['email']) . "', date = '" . $bourbon->request['timestamp'] . "' WHERE form_id = $form_id"); } if ($success) { BourbonUtilities::Redirect($bourbon, $_SERVER['PHP_SELF'] . '?action=page1'); } else { $error_message = array('Your contact information could not be saved.'); } break; case 'save_page1': // get number of performers switch (@$_REQUEST['group_type']) { case 'Solo': $number_of_performers = 1; break; case 'Duet': $number_of_performers = 2; break; case 'Ensemble': $number_of_performers = $_REQUEST['number_of_performers']; break; default: $number_of_performers = 0; $error_message[] = 'You must choose a group type (solo, duet, or ensemble)'; break; } // end if // make sure the user has selected an instrument if (empty($_REQUEST['instrument'])) { $error_message[] = 'You must choose an instrument'; } // end if // make sure the user has selected an instrument if (@$_REQUEST['group_type'] == 'Solo' && empty($_REQUEST['contest_level'])) { $error_message[] = 'You must choose a contest level (Performing, Concert, or Olympic)'; } // end if $fees = ($number_of_performers <= 2 ? $number_of_performers * 20 : $number_of_performers * 10); // start sql statement if ($performance_id) { // updating existing record $sql = "UPDATE performances SET fees = " . $fees . ", number_of_performers = $number_of_performers, updated_at = '" . $bourbon->request['timestamp'] . "'"; } else { // new record $sql = "INSERT INTO performances SET form_id = '" . $form_id . "', fees = " . $fees . ", number_of_performers = $number_of_performers, created_at = '" . $bourbon->request['timestamp'] . "', updated_at = '" . $bourbon->request['timestamp'] . "'"; } // end if // set up list of form fields to be used for validation and database stuff $form_fields = array( //array('name'=>'song', 'type'=>'text', 'required'=>false), array('name'=>'instrument', 'type'=>'text', 'required'=>false), array('name'=>'instrument_details', 'type'=>'text', 'required'=>false), // see below array('name'=>'group_type', 'type'=>'text', 'required'=>false), array('name'=>'contest_level', 'type'=>'text', 'required'=>false), // see below ); foreach ($form_fields as $fld) { $data = @$_REQUEST[$fld['name']]; // contest level is not required (or used) if duet or ensemble if ($fld['name'] == 'contest_level' && @$_REQUEST['group_type'] != 'Solo') continue; // instrument details are only required for percussion // (now this is used for jazz band and mixed ensemble also) //if (!strstr($_REQUEST['instrument'], 'Percussion') && $fld['name'] == 'instrument_details') continue; // validate if required if ($fld['required']) { if (strlen($data) == 0) { $error_message[] = "You must enter your " . ucwords(str_replace('_', ' ', $fld['name'])) . "."; } else if ($fld['type'] == 'email' && !ereg("^.+@.+\..+$",$data)) { $error_message[] = "Your " . ucwords(str_replace('_', ' ', $fld['name'])) . " is not valid."; } } // process data and add to sql statement switch ($fld['type']) { case 'email': $data = str_replace("\n", "", $data); $data = str_replace("\r", "", $data); break; } $sql .= ', ' . $fld['name'] . " = '" . $bourbon_db->EscapeString($data) . "'"; } // next if ($performance_id) { $sql .= " WHERE performance_id = $performance_id"; } // end if if (count($error_message) == 0) { // validation passed; add to database $bourbon_db->Query($sql); // get id if new record if (!$performance_id) $performance_id = $bourbon_db->InsertID(); BourbonUtilities::Redirect($bourbon, $_SERVER['PHP_SELF'] . '?action=page2&performance_id=' . $performance_id); } else { // validation failed; stay on same page $action = 'page1'; } // end if break; case 'save_page2': $performance_data = $bourbon_db->GetRecord("SELECT * FROM performances WHERE performance_id = " . (int) $performance_id); $number_of_performers = $performance_data[0]['number_of_performers']; $total_experience = 0; // check for correct number of students $student_count = 0; for ($i=0;$i<20;$i++) { if (!empty($_REQUEST['student_first_name'][$i]) && !empty($_REQUEST['student_last_name'][$i]) && !empty($_REQUEST['age'][$i]) && !empty($_REQUEST['years_experience'][$i])) { $student_count++; $total_experience += (int) $_REQUEST['years_experience'][$i]; } } // next if ($student_count == $number_of_performers) { // purge existing student records $bourbon_db->Query("DELETE FROM students WHERE performance_id = $performance_id",$db); // save students to database for ($i=0;$i<20;$i++) { if (!empty($_REQUEST['student_first_name'][$i])) { $bourbon_db->Query("INSERT INTO students SET performance_id = $performance_id, first_name = '" . $bourbon_db->EscapeString($_REQUEST['student_first_name'][$i]) . "', last_name = '" . $bourbon_db->EscapeString($_REQUEST['student_last_name'][$i]) . "', age = '" . $bourbon_db->EscapeString($_REQUEST['age'][$i]) . "', years_experience = '" . $bourbon_db->EscapeString($_REQUEST['years_experience'][$i]) . "'"); } } // next BourbonUtilities::Redirect($bourbon, $_SERVER['PHP_SELF'] . '?action=page3&performance_id=' . $performance_id); } else { // validation failed; stay on same page $error_message[] = "You specified $number_of_performers performers, but you entered $student_count students. Student information must include first name, last name, age, and years of experience."; $action = 'page2'; } break; case 'save_page3': $performance_data = $bourbon_db->GetRecord("SELECT * FROM performances WHERE performance_id = " . (int) $performance_id); $performance_data = $performance_data[0]; if (isset($_REQUEST['length_of_performance'])) { $bourbon_db->Query("UPDATE performances SET length_of_performance = '" . $bourbon_db->EscapeString($_REQUEST['length_of_performance']) . "', updated_at = '" . $bourbon->request['timestamp'] . "' WHERE performance_id = " . $performance_data['performance_id']); BourbonUtilities::Redirect($bourbon, 'entry_form.php?action=list'); } else { $action = 'page3'; } break; case 'delete_confirm': $bourbon_db->Query("DELETE FROM students WHERE performance_id = $performance_id"); $bourbon_db->Query("DELETE FROM performances WHERE performance_id = $performance_id"); BourbonUtilities::Redirect($bourbon, $_SERVER['PHP_SELF'] . "?action=list"); break; case 'set_phone': // the "login" system for the site //$bourbon_db->show_queries = true; $phone = preg_replace('/[^0-9-]/', '', @$_REQUEST['phone']); if (!empty($phone)) { $_SESSION['phone'] = $phone; if ($form_id = $bourbon_db->CellQuery("SELECT form_id FROM forms WHERE REPLACE(phone, '-', '') = '" . str_replace('-', '', $bourbon_db->EscapeString($phone)) . "' AND status = 'In Progress' ORDER BY form_id DESC LIMIT 1")) { echo '$form_id = ' . $form_id . '
'; $_SESSION['form_id'] = $form_id; } BourbonUtilities::Redirect($bourbon, $_SERVER['PHP_SELF'] . "?action=list"); } break; } // set up the variables to use when populating the form fields // blank variables (defaults) //$song = ''; $instrument = ''; $instrument_details = ''; $group_type = ''; $number_of_performers = ''; $contest_level = ''; // arrays of students data $student_first_name = array(); $student_last_name = array(); $age = array(); $years_experience = array(); if ($performance_id) { // either editing page 1 or on page 2 or 3 for any reason // (those pages are always considered "edits" as they change a row that was added on page 1) $performance_data = $bourbon_db->GetRecord("SELECT * FROM performances WHERE performance_id = " . $performance_id); //$song = $performance_data[0]['song']; $instrument = $performance_data[0]['instrument']; $instrument_details = $performance_data[0]['instrument_details']; $group_type = $performance_data[0]['group_type']; $number_of_performers = $performance_data[0]['number_of_performers']; $contest_level = $performance_data[0]['contest_level']; $length_of_performance = $performance_data[0]['length_of_performance']; //$notes = $performance_data[0]['notes']; $fees = ($number_of_performers <= 2 ? $number_of_performers * 20 : $number_of_performers * 10); $result = $bourbon_db->Query("SELECT * FROM students WHERE performance_id = " . $performance_id . " ORDER BY student_id"); while ($student_data = $bourbon_db->FetchArray($result)) { $student_first_name[] = $student_data['first_name']; $student_last_name[] = $student_data['last_name']; $age[] = $student_data['age']; $years_experience[] = $student_data['years_experience']; } // loop } // now overwrite the database values, if used, with the request variables, if they exist //if (isset($_REQUEST['song'])) $song = @$_REQUEST['song']; if (isset($_REQUEST['instrument'])) $instrument = @$_REQUEST['instrument']; if (isset($_REQUEST['instrument_details'])) $instrument_details = @$_REQUEST['instrument_details']; if (isset($_REQUEST['group_type'])) $group_type = @$_REQUEST['group_type']; if (isset($_REQUEST['number_of_performers'])) $number_of_performers = @$_REQUEST['number_of_performers']; if (isset($_REQUEST['contest_level'])) $contest_level = @$_REQUEST['contest_level']; if (isset($_REQUEST['length_of_performance'])) $length_of_performance = @$_REQUEST['length_of_performance']; //if (isset($_REQUEST['notes'])) $notes = @$_REQUEST['notes']; if (isset($_REQUEST['student_first_name'])) $student_first_name = @$_REQUEST['student_first_name']; if (isset($_REQUEST['student_last_name'])) $student_last_name = @$_REQUEST['student_last_name']; if (isset($_REQUEST['age'])) $age = @$_REQUEST['age']; if (isset($_REQUEST['years_experience'])) $years_experience = @$_REQUEST['years_experience']; // for page 3, calculate the maximum performance length if ($action == 'page3') { if ($group_type == 'Ensemble') { $maximum_length = 15; } else if ($contest_level == 'Olympic') { $maximum_length = 12; } else { // calculate maximum length based on the performers' years of experience $average_experience = $bourbon_db->CellQuery("SELECT AVG(ABS(years_experience)) FROM students WHERE performance_id = " . $performance_id); if ($average_experience < 2) { $maximum_length = 3; } else if ($average_experience < 3) { $maximum_length = 3.5; } else if ($average_experience < 4) { $maximum_length = 4; } else if ($average_experience < 5) { $maximum_length = 5; } else if ($average_experience < 6) { $maximum_length = 6; } else if ($average_experience < 7) { $maximum_length = 7; } else { $maximum_length = 10; } } } ?> Granquist Music Competition - Entry Form

Geneva, Illinois

Festivals Shopping Dining Lodging and Accommodations Leisure Activities Chamber of Commerce

We are unable to process your request:

    ' . $value . "\n"; } ?>


Registration for the 2011 competition has been closed. Thank you for your interest.

Granquist Competition Entry Form

Query("SELECT * FROM forms WHERE form_id = " . $form_id); if ($form_data = $bourbon_db->FetchArray($result)) { ?>

Your Entry Form

Your Name
Address

'; ?>
Phone
Email
Query("SELECT * FROM performances WHERE form_id = $form_id AND length_of_performance IS NOT NULL ORDER BY performance_id"); $result = $bourbon_db->FetchResultSet(); if (@mysql_num_rows($result)) { ?>

These are all the performances you have entered so far:

Query("SELECT * FROM students WHERE performance_id = $row[performance_id] ORDER BY student_id LIMIT 3"); $num_students = $bourbon_db->NumRows($result); $student_name = array(); while ($row2 = $bourbon_db->FetchArray($result)) { $student_name[] = $row2['first_name'] . ' ' . $row2['last_name']; } // end if $student_name = join(', ', $student_name); ?>
# Performer(s) Instrument # in group
3) echo " and " . ($num_students - 3) . " other(s)"; ?>

         

This page allows you to register your performers for the Granquist Competition. You will add one performance (solo, duet, or emsemble) at a time. When you have finished entering all of your performances, you will submit your complete list to the Geneva Chamber.

Click here to add a performance

GetRecord("SELECT * FROM performances WHERE performance_id = " . (int) $_REQUEST['performance_id']); $result = $bourbon_db->Query("SELECT * FROM students WHERE performance_id = $performance_id ORDER BY student_id LIMIT 3"); $num_students = $bourbon_db->NumRows($result); $student_name = array(); while ($row2 = $bourbon_db->FetchArray($result)) { $student_name[] = $row2['first_name'] . ' ' . $row2['last_name']; } // end if $student_name = join(', ', $student_name); ?>

You are about to delete the following performance from your list:

3) echo " and " . ($num_students - 1) . " other(s)"; ?>

Are you sure you want to do this?

    

Your entries have been saved so that you may return to the site later to complete your registration.

You may continue your registration later by entering your phone number,