Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con=mysqli_connect('localhost','','','arduino');
- if(mysqli_connect_errno($con))
- {
- echo 'Failed to connect:'.mysqli_connect_error();
- }
- else
- echo 'Connected Successfully!! </br>';
- $url=$_SERVER['REQUEST_URI'];
- $sql = "SELECT
- ID,
- Item_Name,
- Expiry_Date,
- CASE
- WHEN `Expiry_Date` < CURDATE() THEN CONCAT(`Item_Name`,' has EXPIRED already')
- WHEN `Expiry_Date` = CURDATE() THEN CONCAT(`Item_Name`,' will expire today')
- WHEN `Expiry_Date` BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 DAY) THEN CONCAT(`Item_Name`,' will expire tomorrow')
- WHEN `Expiry_Date` > DATE_ADD(CURDATE(), INTERVAL 1 DAY) THEN CONCAT(`Item_Name`,' has not expire yet')
- ELSE 'Error processing expiration date.'
- END AS `Expiration_Message`
- FROM
- test;";
- $result = mysqli_query($con,$sql);
- while($row = mysqli_fetch_array($result)){
- echo ($row['Expiration_Message']);
- echo '<br>';
- }
- print_r($row);
- mysqli_close($con);
- ?>
- <?php
- // Import PHPMailer classes into the global namespace
- // These must be at the top of your script, not inside a function
- use PHPMailerPHPMailerPHPMailer;
- use PHPMailerPHPMailerException;
- //Load composer's autoloader
- require 'vendor/autoload.php';
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- //$mail->SMTPDebug = 1; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'Smtp.live.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'XXXXX@hotmail.com'; // SMTP username
- $mail->Password = 'XXXXX'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom('XXXXX@hotmail.com', 'Smart Fridge');
- $mail->addAddress('XXXXX@gmail.com', 'Joe'); // Add a recipient
- $body= '<p><td><strong>Hello</strong></td> this is my first email!!!!</p>';
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Expiry Date';
- $mail->Body = $body;
- $mail->AltBody = strip_tags($body);
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
Add Comment
Please, Sign In to add comment