matthewst Posted May 9, 2007 Share Posted May 9, 2007 I have a database named blah. In blah I have a table named ninjas. In ninjas are height, weight, number of victims, email If new ninja1 registers and enters height, number of victims, and email but doesn't know his weight how would I automatically email him every 15 days until he enters the missing information? Same question if new ninja2 is missing his height. All the necessary fields are in the same table. Some information will be missing because the users won't have all the information at first, but since the jobs associated with this database are time sensitive we have to get started ASAP (even if we don't have all the info). Quote Link to comment https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/ Share on other sites More sharing options...
pocobueno1388 Posted May 9, 2007 Share Posted May 9, 2007 You will need to use a cron for the every 15 days part. The cron should run a script that uses the mail() function. php.net/mail - How to use it. Quote Link to comment https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/#findComment-249171 Share on other sites More sharing options...
matthewst Posted May 9, 2007 Author Share Posted May 9, 2007 ??? :-\ I don't know what any of the means. I'm just looking for: get date if date is 1 or 15 then query = SELECT * FROM ninjas WHERE email=not null if height || weight || number of victims ="" then send and email to the ninja listing the fields missing info else loop the the next ninja else end Quote Link to comment https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/#findComment-249193 Share on other sites More sharing options...
AikenDrum Posted May 10, 2007 Share Posted May 10, 2007 cron is a scheduling demon in Unix and Unix-similar operating systems (Linux etc) AikenD Quote Link to comment https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/#findComment-249668 Share on other sites More sharing options...
matthewst Posted May 11, 2007 Author Share Posted May 11, 2007 Thanks to lostboy from weberfourms I'll be setting up a cron job to run the page every 15 days. <?php error_reporting(E_ALL); include('include/db_con.php'); /*If (date("d") != 1 || date("d")!=15){ exit; }*/ $query="SELECT * FROM table_name WHERE (order_year > '2006' || order_date > '05/01/2007') & (table_type = '' || qty_oak = '0' & qty_nooak = '0' || contact_fname = '' || rest_address_1 = '' || rest_phone_sf = '0' || corners = '' || stain = '' || paint = '')"; $result=mysql_query($query); while($row = mysql_fetch_assoc($result)){ $dist_id = $row['dist_id']; $table_type = $row['table_type']; $stain = $row['stain']; $paint = $row['paint']; $qty_oak = $row['qty_oak']; $qty_nooak = $row['qty_nooak']; $contact_fname = $row['contact_fname']; $rest_name = $row['rest_name']; $rest_address = $row['rest_address_1']; $rest_phone_sf = $row['rest_phone_sf']; $corners = $row['corners']; $stain = $row['stain']; $paint = $row['paint']; $bg_colors = $row['bg_colors']; $bg_img = $row['bg_img']; $bd_colors = $row['bd_colors']; $order_year = $row['order_year']; $order_date = $row['order_date']; $query2="SELECT * FROM sales_rep WHERE sales_id=$dist_id"; $result2=mysql_query($query2); while($row2 = mysql_fetch_assoc($result2)){ $email = $row2['email']; $fname = $row2['fname']; //for testing /*echo "$fname, you are missing:<br>"; if ($table_type == "") { echo "type of table<br>"; } if ($qty_oak != "0" & $stain == "") { echo "stain number<br>"; } if ($qty_nooak != "0" & $paint == "") { echo "paint number<br>"; } if ($contact_fname == "") { echo "restaurant contact<br>"; } if ($rest_address == "") { echo "restaurant address<br>"; } if ($rest_phone_sf == "0") { echo "restaurant phone number<br>"; } if ($corners == "") { echo "size of corners<br>"; } if ($bg_colors == "") { echo "background colors<br>"; } if ($bg_img == "") { echo "background image<br>"; } if ($bd_colors == "") { echo "border color<br>"; } echo "for $rest_name <br><br>";}}*/ //end testing if ($result && mysql_num_rows($result) > 0) { $message = "Hey $fname,\n\nYou are missing some of the table order info for $rest_name. We need:\n\n"; //clear the message // add an empty string to ensure that you are comparing apples to apples if ($table_type == "") { $message .= "The type of table\n"; } if ($qty_oak != "0" & $stain == "") { $message .= "The stain number\n"; } if ($qty_nooak != "0" & $paint == "") { $message .= "The paint number\n"; } if ($contact_fname == "") { $message .= "A contact at the restaurant\n"; } if ($rest_address == "") { $message .= "The restaurant address\n"; } if ($rest_phone_sf == "0") { $message .= "The resturant phone number\n"; } if ($corners == "") { $message .= "Corner size\n"; } if ($bg_colors == "") { $message .= "Background colors\n"; } if ($bg_img == "") { $message .= "Background image\n"; } if ($bd_colors == "") { $message .= "Border colors\n"; } } $message .= "\nPlease send us the missing info ASAP.\n\nThanks, ABC"; $subject = "We need some information for $rest_name"; //email headers $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"Admin\" <abc@abc.net>\n"; $headers .= "Return-Path: abc@abc.net\n"; $headers .= "Return-Receipt-To: abc@abc.net\n"; /* $headers .= "CC:$cc\r\n"; //if you want 'em $headers .= "BCC:$bcc\r\n"; */ if(!mail($email,$subject,$message,$headers)){ echo "There has been a mail error sending to " . $to . "<br>"; } }} ?> Quote Link to comment https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/#findComment-250465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.