Guest User

Untitled

a guest
Nov 13th, 2017
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <?php
  2.  
  3. $con=mysqli_connect('localhost','','','arduino');
  4.  
  5. if(mysqli_connect_errno($con))
  6. {
  7. echo 'Failed to connect:'.mysqli_connect_error();
  8. }
  9. else
  10. echo 'Connected Successfully!! </br>';
  11. $url=$_SERVER['REQUEST_URI'];
  12. $sql = "SELECT
  13. ID,
  14. Item_Name,
  15. Expiry_Date,
  16. CASE
  17. WHEN `Expiry_Date` < CURDATE() THEN CONCAT(`Item_Name`,' has EXPIRED already')
  18. WHEN `Expiry_Date` = CURDATE() THEN CONCAT(`Item_Name`,' will expire today')
  19. WHEN `Expiry_Date` BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 DAY) THEN CONCAT(`Item_Name`,' will expire tomorrow')
  20. WHEN `Expiry_Date` > DATE_ADD(CURDATE(), INTERVAL 1 DAY) THEN CONCAT(`Item_Name`,' has not expire yet')
  21. ELSE 'Error processing expiration date.'
  22. END AS `Expiration_Message`
  23. FROM
  24. test;";
  25.  
  26. $result = mysqli_query($con,$sql);
  27.  
  28.  
  29. while($row = mysqli_fetch_array($result)){
  30. echo ($row['Expiration_Message']);
  31. echo '<br>';
  32. }
  33.  
  34. print_r($row);
  35.  
  36. mysqli_close($con);
  37.  
  38. ?>
  39.  
  40. <?php
  41. // Import PHPMailer classes into the global namespace
  42. // These must be at the top of your script, not inside a function
  43. use PHPMailerPHPMailerPHPMailer;
  44. use PHPMailerPHPMailerException;
  45.  
  46. //Load composer's autoloader
  47. require 'vendor/autoload.php';
  48.  
  49. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  50. try {
  51. //Server settings
  52. //$mail->SMTPDebug = 1; // Enable verbose debug output
  53. $mail->isSMTP(); // Set mailer to use SMTP
  54. $mail->Host = 'Smtp.live.com'; // Specify main and backup SMTP servers
  55. $mail->SMTPAuth = true; // Enable SMTP authentication
  56. $mail->Username = 'XXXXX@hotmail.com'; // SMTP username
  57. $mail->Password = 'XXXXX'; // SMTP password
  58. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  59. $mail->Port = 587; // TCP port to connect to
  60.  
  61. //Recipients
  62. $mail->setFrom('XXXXX@hotmail.com', 'Smart Fridge');
  63. $mail->addAddress('XXXXX@gmail.com', 'Joe'); // Add a recipient
  64. $body= '<p><td><strong>Hello</strong></td> this is my first email!!!!</p>';
  65.  
  66. //Content
  67. $mail->isHTML(true); // Set email format to HTML
  68. $mail->Subject = 'Expiry Date';
  69. $mail->Body = $body;
  70. $mail->AltBody = strip_tags($body);
  71.  
  72. $mail->send();
  73. echo 'Message has been sent';
  74. } catch (Exception $e) {
  75. echo 'Message could not be sent.';
  76. echo 'Mailer Error: ' . $mail->ErrorInfo;
  77. }
Add Comment
Please, Sign In to add comment