query($sql))) { die($result->getUserInfo()); } $record = $result->fetchRow(DB_FETCHMODE_ASSOC); return ($record['count'] > 0); } /*********************************************************************\ main() \*********************************************************************/ function main () { global $dbh; $fields = array( "age" => "", "name" => "", "email" => "", "address" => "", "city" => "", "state" => "", "zip" => "", "phone" => "", ); // define mail list info for update checkboxes $join_lists = array( "join_artist" => "musicfromtheoc" ); // define db column info for update checkboxes $db_fields = array( "join_artist" => "join_artist" ); $submitted_form = false; $missing_fields = false; $duplicate_user = false; // verify that all requried form information is present foreach(array_keys($fields) as $field_name) { if (isset($_POST[$field_name])) { $submitted_form = true; if ($_POST[$field_name] == "") { $missing_fields = true; } else { $fields[$field_name] = trim(strip_tags($_POST[$field_name])); } } } // validate email if (isset($_POST['email']) && !email_validate($fields['email'])) { $missing_fields = true; $fields['email'] = ""; } // check for duplicate email address $duplicate_user = is_duplicate($fields['email']); // check submission, if any, and generate output if ($submitted_form && !$missing_fields && !$duplicate_user) // do the dirty data processing work { // build db insert query $columns = array(); $values = array(); foreach($fields as $field_name => $field_value) { array_push($columns, $field_name); array_push($values, addslashes($field_value)); } array_push($columns, $db_fields['join_artist']); array_push($values, ($_POST['join_artist']) ? 1 : 0); // enter into contest database $sql = sprintf("insert into %s (%s) values ('%s')", 'oc_ipod', join(",", $columns), join("','",$values)); //printf("\n\n\n\n\n", $sql); if (DB::isError($result = $dbh->query($sql))) { die($result->getUserInfo()); } // submit to lyris join form if($_POST['join_artist']) { join_mail_list($fields['email'], $join_lists['join_artist']); } //readfile("thanks.html"); print_thanks($fields); } else // print the contest submission form { // store answers for any selected lists foreach(array_keys($join_lists) as $list_code) { if (isset($_POST[$list_code])) { $fields[$list_code] = $_POST[$list_code]; } } print_form($fields, $missing_fields, $duplicate_user); } } /*********************************************************************\ join_mail_list($email_address, $list_name) 'GET's a virtual form (poor mans' RPC) to lyris join script \*********************************************************************/ function join_mail_list($email_address, $list_name) { $lyris_url = "http://www.warnerreprise.com/lyris/join_list.php"; $lyris_args = array( "email" => urlencode($email_address), "list" => urlencode($list_name), "good" => "default", "error" => "default" ); $qparams = array(); foreach($lyris_args as $qkey => $qval ) $qparams[] = $qkey."=".$qval; $get_url = $lyris_url.'?'.join('&',$qparams); //printf("

joining list '%s' with '%s' at '%s'

\n", $list_name, $email_address, $get_url); $lyris_results = file_get_contents($get_url); //echo "
".$lyris_results."
\n\n\n\n\n\n\n"; } /*********************************************************************\ print_header() \*********************************************************************/ function print_header() { ?> MUSIC FROM THE OC, MIX 4 POD CONTEST
Win Some things!

<- required"; $duplicate_message = "<- already entered"; ?>

ENTER THE "MIX-IT-UP" CONTEST

The 4th installment of Music From The OC is coming on April 5, 2005, and to celebrate, we're giving away an 20GB iPod engraved with "Music from the OC" and pre-loaded with the new Mix 4 and Mixes 1, 2 and 3, plus a pair of tickets to see The Futureheads (featured on Mix 4) on tour in April at a city nearest you! Two runners-up will receive a pair of tickets each in their closest city.
 
Enter now and you might be able to mix up the mixes on a new iPod!

Good luck!

All fields required

Name:
Age:
Email:
Address:
City:
State:
Postal/Zip Code:
Phone Number:
Get email updates from
Music from The OC

Thanks!