Jump to content

Recommended Posts

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).

Link to comment
https://forums.phpfreaks.com/topic/50687-solved-how-do-i-auto-email-users/
Share on other sites

:o ??? :-[ :-\

 

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

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>"; 
  } 

}}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.