I hope someone can help me, providing advice, tips, or guide me to achieve the following: I need to send an email to the person who created the application when there are 2 weeks left before the initial date of the course begins, so far I only have the following query in my database but I really don't know how to achieve what I need, on my server I already have PHPMailer and I send emails in other cases and it works without problems.
SELECT dd_mm_inicio, if((dd_mm_inicio - INTERVAL 2 WEEK) = CURDATE(), "TRUE", "FALSE")
FROM servicio where id_formulario_1=7
When there are exactly 2 weeks left before the start date, mail is sent at 9:00 am, only on that day.
you can do it like this:
since the only thing you need is to validate that it is before 2 weeks if you want to validate another field, it would be enough to add it with:
now to run it just suffice with:
Now it would only be enough to add it to a crontab or to the windows task scheduler
so that it runs 1 or 2 times a day.
Try the date function:
you can consult the different formats in
https://www.w3schools.com/php/func_date_date.asp
What you need is to make a scheduled task that runs every day at 9:00 am and that checks if there are any in your table of courses that are 2 weeks away from starting and thus notify.
The most common way to do this is using crontab, I leave you a link with everything you need to know to mount it:
https://geekflare.com/crontab-linux-with-real-time-examples-and-tools/
Summarizing:
I hope I have helped.
Cheers