Advertisement
Guest User

Untitled

a guest
May 28th, 2017
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.19 KB | None | 0 0
  1. <?php
  2.     $result = mysql_query("SELECT username, due, name, course, emailbefore FROM assignments");
  3.     while ($row = mysql_fetch_array($result)) {
  4.         if ($row['emailbefore'] != "false") {
  5.             if ($row['emailbefore'] == "1d") {
  6.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24))) {
  7.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  8.                     $arow = mysql_fetch_array($aresult);
  9.                     $to = $arow['email'];
  10.                     $subject = "Your Assignment Due Notice";
  11.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  12.                                 "Name: $row['name']\n" .
  13.                                 "Due Date: $row['due']\n" .
  14.                                 "Course: $row['course']\n" .
  15.                                 "If you feel that this is a mistake, please reply to this email.";
  16.                     $headers = "From: Support@Johtaja.co.tv";
  17.                    
  18.                     mail($to,$subject,$message,$headers);
  19.                 }
  20.             }
  21.             elseif ($row['emailbefore'] == "2d") {
  22.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*2))) {
  23.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  24.                     $arow = mysql_fetch_array($aresult);
  25.                     $to = $arow['email'];
  26.                     $subject = "Your Assignment Due Notice";
  27.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  28.                                 "Name: $row['name']\n" .
  29.                                 "Due Date: $row['due']\n" .
  30.                                 "Course: $row['course']\n" .
  31.                                 "If you feel that this is a mistake, please reply to this email.";
  32.                     $headers = "From: Support@Johtaja.co.tv";
  33.                    
  34.                     mail($to,$subject,$message,$headers);
  35.                 }
  36.             }
  37.             elseif ($row['emailbefore'] == "3d") {
  38.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*3))) {
  39.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  40.                     $arow = mysql_fetch_array($aresult);
  41.                     $to = $arow['email'];
  42.                     $subject = "Your Assignment Due Notice";
  43.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  44.                                 "Name: $row['name']\n" .
  45.                                 "Due Date: $row['due']\n" .
  46.                                 "Course: $row['course']\n" .
  47.                                 "If you feel that this is a mistake, please reply to this email.";
  48.                     $headers = "From: Support@Johtaja.co.tv";
  49.                    
  50.                     mail($to,$subject,$message,$headers);
  51.                 }
  52.             }
  53.             elseif ($row['emailbefore'] == "4d") {
  54.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*4))) {
  55.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  56.                     $arow = mysql_fetch_array($aresult);
  57.                     $to = $arow['email'];
  58.                     $subject = "Your Assignment Due Notice";
  59.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  60.                                 "Name: $row['name']\n" .
  61.                                 "Due Date: $row['due']\n" .
  62.                                 "Course: $row['course']\n" .
  63.                                 "If you feel that this is a mistake, please reply to this email.";
  64.                     $headers = "From: Support@Johtaja.co.tv";
  65.                    
  66.                     mail($to,$subject,$message,$headers);
  67.                 }
  68.             }
  69.             elseif ($row['emailbefore'] == "5d") {
  70.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*5))) {
  71.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  72.                     $arow = mysql_fetch_array($aresult);
  73.                     $to = $arow['email'];
  74.                     $subject = "Your Assignment Due Notice";
  75.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  76.                                 "Name: $row['name']\n" .
  77.                                 "Due Date: $row['due']\n" .
  78.                                 "Course: $row['course']\n" .
  79.                                 "If you feel that this is a mistake, please reply to this email.";
  80.                     $headers = "From: Support@Johtaja.co.tv";
  81.                    
  82.                     mail($to,$subject,$message,$headers);
  83.                 }
  84.             }
  85.             elseif ($row['emailbefore'] == "6d") {
  86.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*6))) {
  87.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  88.                     $arow = mysql_fetch_array($aresult);
  89.                     $to = $arow['email'];
  90.                     $subject = "Your Assignment Due Notice";
  91.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  92.                                 "Name: $row['name']\n" .
  93.                                 "Due Date: $row['due']\n" .
  94.                                 "Course: $row['course']\n" .
  95.                                 "If you feel that this is a mistake, please reply to this email.";
  96.                     $headers = "From: Support@Johtaja.co.tv";
  97.                    
  98.                     mail($to,$subject,$message,$headers);
  99.                 }
  100.             }
  101.             elseif ($row['emailbefore'] == "1w") {
  102.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*7))) {
  103.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  104.                     $arow = mysql_fetch_array($aresult);
  105.                     $to = $arow['email'];
  106.                     $subject = "Your Assignment Due Notice";
  107.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  108.                                 "Name: $row['name']\n" .
  109.                                 "Due Date: $row['due']\n" .
  110.                                 "Course: $row['course']\n" .
  111.                                 "If you feel that this is a mistake, please reply to this email.";
  112.                     $headers = "From: Support@Johtaja.co.tv";
  113.                    
  114.                     mail($to,$subject,$message,$headers);
  115.                 }
  116.             }
  117.             elseif ($row['emailbefore'] == "2w") {
  118.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*14))) {
  119.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  120.                     $arow = mysql_fetch_array($aresult);
  121.                     $to = $arow['email'];
  122.                     $subject = "Your Assignment Due Notice";
  123.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  124.                                 "Name: $row['name']\n" .
  125.                                 "Due Date: $row['due']\n" .
  126.                                 "Course: $row['course']\n" .
  127.                                 "If you feel that this is a mistake, please reply to this email.";
  128.                     $headers = "From: Support@Johtaja.co.tv";
  129.                    
  130.                     mail($to,$subject,$message,$headers);
  131.                 }
  132.             }
  133.             elseif ($row['emailbefore'] == "3w") {
  134.                 if (date('F j Y', $row['due']) <= date('F j Y', time()+(60*60*24*21))) {
  135.                     $aresult = mysql_query("SELECT email FROM users WHERE username='$row['username']'");
  136.                     $arow = mysql_fetch_array($aresult);
  137.                     $to = $arow['email'];
  138.                     $subject = "Your Assignment Due Notice";
  139.                     $message = "This is a notice for your Johtaja account. You asked us to send you an email about an assignment, so here it is. Information about the assignment:\n" .
  140.                                 "Name: $row['name']\n" .
  141.                                 "Due Date: $row['due']\n" .
  142.                                 "Course: $row['course']\n" .
  143.                                 "If you feel that this is a mistake, please reply to this email.";
  144.                     $headers = "From: Support@Johtaja.co.tv";
  145.                    
  146.                     mail($to,$subject,$message,$headers);
  147.                 }
  148.             }
  149.         }
  150.     }
  151. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement