= 2) { foreach($preproc as $row) { //If row count down is at 1, this is the last procedure //add a comma, the procedure, and then a period if($rowcountdown == 1) { $procedures .= ", ".$row."."; } //If the rowcountdown is the same as the row count //Then this is the first procedure. List it without a //leading comma and reduce row count down by 1 elseif($rowcountdown == $rowcount) { $procedures .= $row; $rowcountdown = $rowcountdown - 1; } //Otherwise, it is somewhere in the middle. //List with leading comma, reduce row count down by 1 else { $procedures .= ", ".$row; $rowcountdown = $rowcountdown - 1; } } } //If the rowcown variable is 0 or less, there are no procedures else { $procedures = "None."; } //Build outbound e-mail //Enables reply feature on receiving clients by having the email here $email_from = $email; //Subject for mail message $email_subject = "AZDiscountSpa.com Model Treatment Request - ".$name; //Body of the message $email_body .= "Name: ".$name." "; $email_body .= "City: ".$city." "; $email_body .= "E-Mail Address: ".$email." "; $email_body .= "Phone Number: ".$number." "; $email_body .= "Best Time to Call: ".$timetocall." "; $email_body .= "Location: ".$location." "; $email_body .= "Procedures: ".$procedures." "; $email_body .= "Questions: ".$questions." "; $email_body .= "------------------------------------------------------------------------------------------- "; $email_body .= "Visitor's IP Address: ".$ip." "; //Creates a header so the Name and E-mail are easier to read $header = "From: ".$name." <" . $email . ">\r\n"; //Mail to Spa include('rotation_leads_spa.php'); if(mail($mailto,$email_subject,$email_body,$header) == TRUE) { include('mysql.php'); //Update time stamp to show there was a request for information on this date $sql = "UPDATE model_leads SET timestamp=".mktime()." WHERE leadid=".$lead['leadid']; mysql_query($sql); //Build MySQL insert query $sql = "INSERT INTO models_form (name,city,email,number,timetocall,location,questions,ip,procedures,date,spalead) VALUES ('$name','$city','$email','$number','$timetocall','$location','$questions','$ip','$procedures',NOW(),'$mailto')"; //Insert values into the database mysql_query($sql); } //Mail to eGrabber $egrabber = "egrabber@nlionline.com"; mail($egrabber,$email_subject,$email_body,$header); //Mail to Shelley B. //$instructor="shelleyb333@cox.net"; //mail ($instructor,$email_subject,$email_body,$header); $email_subject = "Thank You for your Treatment Request!"; $email_body = "Thank you for your request for services at National Laser Institute. Our physicians, nurses and technicians provide the highest quality treatments...at the lowest prices available. One of our representatives will be contacting you shortly to schedule an appointment. If for some reason you do not hear from us within one business day...please to not hesitate to call our luxury medical spa directly at 480-290-7333. All discounts apply at this beautiful location. We look forward to speaking with you! Louis J Silberman President & Founder National Laser Institute www.NLIonline.com"; $header = "From: National Laser Institute <".$mailto.">\r\n"; mail($email,$email_subject,$email_body,$header); header('Location:http://www.azdiscountspa.com/thankyou'); ?>