contest_name = 'wp_contest_October_2013_T22_Tennis_Shoes'; $contest_formal_name = ''; $this->subject = "See what we are giving away at Fushion Magazine!"; ///////////////////// // Thank you page // //////////////////// $this->response = "



Thank you!

Your entry has been accepted.

Good luck!

"; ///////////////////////////// // Non-subscriber Message // //////////////////////////// $this->nonsubscriber = "


There was a problem with your entry.

You are NOT a Fushion Magazine subscriber and/or also did not enter a Twitter, Facebook or Pinterest ID.

To become a Fushion Magazine subscriber, please
go here to subscribe.

If you think you may have mistyped your susbcriber email address or would prefer to enter this contest using only your Twitter, Facebook or Pinterest ID, please please go here to correct or re-enter.

"; ///////////////////////////////////////////////////////// // Check to see if entrant has already entered contest // ///////////////////////////////////////////////////////// $this->response_dup = "

Error: This email address has already entered this contest. Please use a different one.

"; $this->form ='

Fushion Contest


You MUST either be a Fushion Magazine subscriber, or follow Fushion Magazine on Facebook, Twitter or Pinterest in order to enter this contest

All winners will be verified before prizes are awarded

Fields denoted with a * are required
First Name:*

Last Name:*

Email:*

Confirm Email:*:

Phone:* Use (xxx-xxx-xxxx) format

Zip Code:*

Age Range:*
If you are following us on Twitter and retweeting this, please include your Twitter I.D. here so we can match your entry with your Twitter account.
Twitter ID:

If you are following us on Facebook, please include your Facebook I.D. here so we can match your entry with your Facebook account.
Facebook ID:

If you are following us on Pinterest, please include your Pinterest I.D. here so we can match your entry with your Pinterest account.
Pinterest ID:


'; //////////////////// // Set Variables // /////////////////// $this->msg = ''; if ( ! isset( $_POST['contest_register'] ) ) return; $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $zipcode = $_POST["zipcode"]; $agerange = $_POST["agerange"]; $twitter = $_POST["twitter"]; $facebook = $_POST["facebook"]; $pinterest = $_POST["pinterest"]; $contest_type = $_POST["contest_type"]; //////////////////// // Perform Checks // /////////////////// // Check for non-subscriber if ($this->check_user($email) && $twitter == '' && $facebook == '') : $this->msg .= $this->nonsubscriber; $this->form = ''; // Check for duplicate contest entry elseif ($this->user_exists($email)) : $this->msg .= $this->response_dup; $this->form = ''; // Else insert entrant else : $this->insert_user($firstname, $lastname, $email, $phone, $zipcode, $agerange, $twitter, $facebook, $pinterest, $contest, $cdate, $contest_formal_name); $this->msg .= $this->response; $this->form = ''; endif; } // end constructor ////////////////////////////////////////////////////// // Check to see if entrant is a current subscriber // ///////////////////////////////////////////////////// function check_user($email = '') { global $wpdb; // Query the database $result = mysql_query("SELECT * FROM lm_users WHERE email_address = '$email'") or die(mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows == 0) { return true; } else { $subscriber = $email; } } ///////////////////////////////////////////////////////////////// // Check to see if entrant is already entered into the contest // ///////////////////////////////////////////////////////////////// function user_exists($email = '') { global $wpdb; // Query the database $result = $wpdb->get_var("SELECT ID FROM {$wpdb->prefix}contest_October_2013_T22_Tennis_Shoes WHERE email = '$email'"); if ( $result ) return true; } //////////////////////////////////////// // Insert entrant into contest table // /////////////////////////////////////// function insert_user($firstname = '', $lastname = '', $email = '', $phone = '', $zipcode = '', $agerange = '', $twitter = '', $facebook = '', $pinterest = '', $contest = '') { global $wpdb; // Get the entrant's date $cdate = date("Y-m-d H:i:s"); // Insert Entrant Data $wpdb->query("INSERT INTO {$wpdb->prefix}contest_October_2013_T22_Tennis_Shoes(firstname,lastname,email,phone,zipcode,agerange,subscriber,twitter,facebook,pinterest,contest_name,cdate) VALUES ('$firstname','$lastname','$email','$phone','$zipcode','$agerange','$subscriber','$twitter','$facebook','$pinterest','$contest','$cdate')"); } } // end class fushion_contest $fushion_contest = new fushion_contest(); ?>