0){ $srow = mysqli_fetch_assoc($get_styles); if(!empty($srow['background_color'])){ $background_color = $srow['background_color']; } if(!empty($srow['text_color'])){ $text_color = $srow['text_color']; } if(!empty($srow['field_color'])){ $field_color = $srow['field_color']; } if(!empty($srow['field_text_color'])){ $field_text_color = $srow['field_text_color']; } if(!empty($srow['field_font_size'])){ $field_font_size = $srow['field_font_size']; } if(!empty($srow['field_font_weight'])){ $field_font_weight = $srow['field_font_weight']; } $title = $srow['title']; // allow this to be emtpy if(!empty($srow['title_color'])){ $title_color = $srow['title_color']; } if(!empty($srow['title_size'])){ $title_size = $srow['title_size']; } if(!empty($srow['title_weight'])){ $title_weight = $srow['title_weight']; } if(!empty($srow['button_text'])){ $button_text = $srow['button_text']; } if(!empty($srow['button_color'])){ $button_color = $srow['button_color']; } if(!empty($srow['button_text_color'])){ $button_text_color = $srow['button_text_color']; } if(!empty($srow['button_hover_color'])){ $button_hover_color = $srow['button_hover_color']; } if(!empty($srow['button_hover_text_color'])){ $button_hover_text_color = $srow['button_hover_text_color']; } } ?> Message); // $Message = stripslashes($this->Message); // $headers = ""; // $headers .="From: ".$this->FromName. // "<".$this->FromMail.">\n"; // $headers .="Reply-to: ".$this->FromName. // "<".$this->FromMail.">\n"; // $headers .="Origin: ".$_SERVER['REMOTE_ADDR']."\n"; // mail($this->ToMail, $this->Subject, $Message, // $headers); // // } // //} // // //// some functions //function validEmail($email){ // if (!preg_match("/([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)@(([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4}))/i", $email)){ // $isValid = false; // }else{ // $isValid = true; // } // return $isValid; //} function get_zip_info($zip) { //Function to retrieve the contents of a webpage and put it into $pgdata $pgdata =""; //initialize $pgdata $fd = fopen("http://zipinfo.com/cgi-local/zipsrch.exe?zip=$zip","r"); //open the url based on the user input and put the data into $fd while(!feof($fd)) {//while loop to keep reading data into $pgdata till its all gone $pgdata .= fread($fd, 1024); //read 1024 bytes at a time } fclose($fd); //close the connection if (preg_match("/is not currently assigned/", $pgdata)) { $city = ""; $state = ""; }else { $citystart = strpos($pgdata, "Code"); $citystart = $citystart + 35; $pgdata = substr($pgdata, $citystart); $cityend = strpos($pgdata, ""); $city = substr($pgdata, 0, $cityend); $statestart = strpos($pgdata, ""); $statestart = $statestart + 29; $pgdata = substr($pgdata, $statestart); $stateend = strpos($pgdata, ""); $state = substr($pgdata, 0, $stateend); } $zipinfo['city'] = $city; $zipinfo['state'] = $state; return $zipinfo; } // initionalize some vars $firstname = ""; $lastname = ""; $email = ""; $zip = ""; $contact_firstname = ""; $contact_lastname = ""; $contact_email = ""; $contact_zip = ""; $contact_phone = ""; $contact_city = ""; $contact_state = ""; $groom_firstname = ""; $groom_lastname = ""; $groom_email = ""; $groom_zip = ""; $groom_phone = ""; $groom_city = ""; $groom_state = ""; $bride_firstname = ""; $bride_lastname = ""; $bride_email = ""; $bride_zip = ""; $bride_phone = ""; $bride_city = ""; $bride_state = ""; $client_budget = ""; $wedding_date = "0000-00-00 00:00:00"; $email2 = ""; $fiance_firstname = ""; $fiance_lastname = ""; $ceremony_location = ""; $how_hear = ""; $interest_rank = ""; $client_notes = ""; $city = ""; $state = ""; $answer = ""; if(isset($_POST['lead'])){ if(isset($_POST['firstname'])){ $firstname = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z\'.-]/', '', $_POST['firstname'])); } if(isset($_POST['lastname'])){ $lastname = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z\'.-]/', '', $_POST['lastname'])); } if(isset($_POST['fiance_firstname'])){ $fiance_firstname = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z\'.-]/', '', $_POST['fiance_firstname'])); } if(isset($_POST['fiance_lastname'])){ $fiance_lastname = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z\'.-]/', '', $_POST['fiance_lastname'])); } if(isset($_POST['ceremony_location'])){ $ceremony_location = mysqli_real_escape_string($dbconn, $_POST['ceremony_location']); } if(isset($_POST['email'])){ $email = mysqli_real_escape_string($dbconn,filter_var($_POST['email'], FILTER_SANITIZE_EMAIL)); } if(isset($_POST['email2'])){ $email2 = mysqli_real_escape_string($dbconn,filter_var($_POST['email2'], FILTER_SANITIZE_EMAIL)); } if(isset($_POST['phone'])){ $phone = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9+.-]/', '', $_POST['phone'])); } if(isset($_POST['contact_type'])){ $contact_type = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z]/', '', $_POST['contact_type'])); } if(isset($_POST['client_budget'])){ $client_budget = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9a-zA-Z $,._-]/', '', $_POST['client_budget'])); } if(isset($_POST['wedding_date'])){ $wedding_date = mysqli_real_escape_string($dbconn, date("Y-m-d H:i:s", strtotime($_POST['wedding_date']))); } if(isset($_POST['question'])){ $question_array = $_POST['question']; } if(isset($_POST['answer'])){ $answer_array = $_POST['answer']; } if($wedding_date < "1999-12-31 00:00:00"){ // this is if the date is entered too poorly $errors[] = "Wedding date not in acceptable format."; } if(isset($_POST['uid'])){ $user_id = mysqli_real_escape_string($dbconn,preg_replace('/[^0-9]/', '', $_POST['uid'])); if(empty($user_id)){ $errors[] = "Unidentified Photographer"; } }else{ $errors[] = "Unidentified Photographer"; } if(empty($firstname)){ $errors[] = "Missing First Name"; } if(empty($lastname)){ $errors[] = "Missing Last Name"; } if(empty($email)){ $errors[] = "Missing Email"; }else{ if($email == $email2){ // do they match? if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { // Is email valid? $errors[] = "$email is not a valid email address"; } }else{ $errors[] = "Email addresses do not match"; } } $stamp = date("Y-m-d H:i:s"); // current date/time if(isset($errors)){ echo '

Some errors occured.

\n"; echo ''; }else{ // process zip if(!empty($zip)){ $ziplookup = get_zip_info($zip); $city = $ziplookup['city']; $state = $ziplookup['state']; } $contact_firstname = $firstname; $contact_lastname = $lastname; $contact_email = $email; $contact_phone = $phone; if($contact_type == "groom"){ $groom_firstname = $firstname; $groom_lastname = $lastname; $groom_email = $email; $groom_phone = $phone; $bride_firstname = $fiance_firstname; $bride_lastname = $fiance_lastname; } if($contact_type == "bride"){ $bride_firstname = $firstname; $bride_lastname = $lastname; $bride_email = $email; $bride_phone = $phone; $groom_firstname = $fiance_firstname; $groom_lastname = $fiance_lastname; } $save_lead = mysqli_query($dbconn,"INSERT INTO clients (client_id, user_id, bride_firstname, bride_lastname, bride_city, bride_state, bride_zip, bride_email, bride_phone, groom_firstname, groom_lastname, groom_city, groom_state, groom_zip, groom_email, groom_phone, contact_firstname, contact_lastname, contact_city, contact_state, contact_zip, contact_email, contact_phone, how_hear, client_notes, interest_rank, client_budget, entry_date, status) VALUES ('', '$user_id', '$bride_firstname', '$bride_lastname', '$bride_city', '$bride_state', '$bride_zip', '$bride_email', '$bride_phone', '$groom_firstname', '$groom_lastname', '$groom_city', '$groom_state', '$groom_zip', '$groom_email', '$groom_phone', '$contact_firstname', '$contact_lastname', '$contact_city', '$contact_state', '$contact_zip', '$contact_email', '$contact_phone', '$how_hear', '$client_notes', '$interest_rank', '$client_budget', '$stamp', '1')"); $client_id = mysqli_insert_id($dbconn); if(!$save_lead){ echo '

There was an error saving the information.

'; }else{ $save_wedding_date = mysqli_query($dbconn,"INSERT INTO wedding_info(user_id, client_id, wedding_date, ceremony_location)VALUES('$uid','$client_id','$wedding_date','$ceremony_location')"); // save answers to the custom questions /////////////////////////////////////////////////////////////// if(!empty($question_array)){ foreach($question_array as $x => $question){ $selections = ""; $question = mysqli_real_escape_string($dbconn,$question); if(!empty($answer_array[$x])){ $answer = mysqli_real_escape_string($dbconn,$answer_array[$x]); } if($answer != ""){ // if it isn't blank $questions_query_array[] = "('$user_id','$client_id','$question','$answer','$stamp')"; } } } if(isset($questions_query_array) && !empty($questions_query_array)){ $questions_query = implode(",",$questions_query_array); } $save_answers = mysqli_query($dbconn,"INSERT INTO leadform_answers (user_id, client_id, question, answer, date_added) VALUES $questions_query "); // end save answers to the custom questions /////////////////////////////////////////////////////////////// echo '

Thank you for your interest. You will hear from us soon.

'; // send an email to the photog $get_email = mysqli_query($dbconn,"SELECT studio_email FROM users WHERE user_id = '$uid'"); if(mysqli_num_rows($get_email) > 0){ $prow = mysqli_fetch_assoc($get_email); $studio_email = $prow['studio_email']; $lead_info = ""; // assembly lead info $lead_info .= 'Wedding Date: '.date("F j, Y", strtotime($wedding_date)); $lead_info .= "
"; $lead_info .= "
"; $lead_info .= 'The main contact is: '.ucfirst($contact_type); $lead_info .= "
"; if($contact_type == "groom"){ $lead_info .= $groom_firstname.' '.$groom_lastname; }elseif($contact_type == "bride"){ $lead_info .= $bride_firstname.' '.$bride_lastname; }else{ $lead_info .= 'Contact Name: '.$contact_firstname.' '.$contact_lastname; } $lead_info .= "
"; if(!empty($contact_email)){ $lead_info .= 'Email: '.$contact_email; } $lead_info .= "
"; if(!empty($contact_phone)){ $lead_info .= 'Phone: '.preg_replace("/^(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $contact_phone); } $lead_info .= "
"; $lead_info .= "
"; if($contact_type == "groom"){ $lead_info .= 'Bride: '.$bride_firstname.' '.$bride_lastname; }elseif($contact_type == "bride"){ $lead_info .= 'Groom: '.$groom_firstname.' '.$groom_lastname; }else{ $lead_info .= 'Bride: '.$bride_firstname.' '.$bride_lastname; $lead_info .= "
"; $lead_info .= 'Groom: '.$groom_firstname.' '.$groom_lastname; } $lead_info .= "
"; $lead_info .= "
"; if(!empty($ceremony_location)){ $lead_info .= 'Ceremony Location: '.$ceremony_location; } $lead_info .= "
"; $lead_info .= "
"; if(!empty($ceremony_location)){ $lead_info .= 'Client Budget: '.$client_budget; } if(!empty($question_array)){ foreach($question_array as $x => $question){ $lead_info .= "
"; $lead_info .= "
"; $lead_info .= $question.': '.$answer_array[$x]; } } $subject = "You have a new lead in ShootFlow!"; $message = "The ShootFlow Ninjas have detected a new lead has filled out your lead form.\n ". "\n".$lead_info; send_email($studio_email,"ShootFlow",$studio_email,$subject,$message,""); // $mailer = new Email; // $mailer->ToMail = $studio_email; // $mailer->FromMail = "shootflow@shootflow.com"; // $mailer->FromName = "ShootFlow"; // $mailer->Subject = "You have a new lead in ShootFlow!"; // $mailer->Message = "The ShootFlow Ninjas have detected a new lead has filled out your lead form.\n ". // "\n".$lead_info; // // $mailer->SendMail(); } } } }else{ $get_studio_name = mysqli_query($dbconn,"SELECT studio_name FROM users WHERE user_id = '$uid'"); if(mysqli_num_rows($get_studio_name) > 0){ $srow = mysqli_fetch_assoc($get_studio_name); $studio_name = $srow['studio_name']; } echo '
'; echo ''.$title.''; echo '
'; // for dev //// //echo ''; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; // get the customizable questions $questions = array(); $type = array(); $selections = array(); // first see if the photog has some $get_photog_questions = mysqli_query($dbconn,"SELECT * FROM leadform_questions WHERE user_id = '$uid' ORDER BY sortorder ASC"); if(mysqli_num_rows($get_photog_questions) > 0){ while($qrow = mysqli_fetch_assoc($get_photog_questions)){ $questions[] = $qrow['question']; $type[] = $qrow['type']; $selections[] = $qrow['selections']; } }else{ // if none get the defaults $get_default_questions = mysqli_query($dbconn,"SELECT * FROM leadform_questions WHERE user_id = '0' ORDER BY sortorder ASC"); if(mysqli_num_rows($get_default_questions) > 0){ while($qrow = mysqli_fetch_assoc($get_default_questions)){ $questions[] = $qrow['question']; $type[] = $qrow['type']; $selections[] = $qrow['selections']; } } } if(!empty($questions)){ foreach($questions as $key => $question){ if($type[$key] == "TEXT"){ echo '
'; // if(strlen($question) > 20){ // echo $question.'
'; // }else{ echo ''; // } echo ''; echo ''; echo '
'; } if($type[$key] == "TEXTAREA"){ echo '
'; // if(strlen($question) > 50){ // echo $question.'
'; // }else{ echo ''; // } echo ''; echo ''; echo '
'; } if($type[$key] == "SELECT"){ echo '
'; // if(strlen($question) > 20){ // echo $question.'
'; // }else{ echo ''; // } echo ''; echo ''; echo '
'; } } } echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; } ?>