03-13-2007, 05:32 PM
I'm not sure how this would work automatically but I was wondering how I can send myself an email say 2 weeks before a member in my database is about to have a birthday? I'm assuming the query would need to be running constantly so would it be possible?
03-13-2007, 08:16 PM
Use can use a CRON job to check each day, or rely on at least
one visitor to your site to execute a PHP script when the page
is viewed. Your page needs the extension .php (example: index.php).
Program your birthday checking script right at the top of the page and
run it each time someone visits the page. Everything will happen without
affecting anything on your webpage.
You could use it to send other reminders too.
03-13-2007, 09:58 PM
I need help in writing the php file :( I'm only just learning and this is beyond me, I have been trying, I have the SQL Query sorted (I think) but I need to set up the page to send the email...
03-13-2007, 10:35 PM
For now, create a PHP script that echoes the birthday to the screen,
using your MySQL database. Once you can get it to appear on the
screen, sending the email is easy.
Make the script in a stand-alone file ... maybe call it "birthday.php" and
get it working to display on the screen when that script is displayed.
It should display the birthday message and the email of the birthday "boy" or "girl".
Getting that far would be a good PHP project for you to learn new things.
We'll deal with the email part later, once we can see you have it working.
03-14-2007, 01:14 AM
Ok well I thought I had it but this doesn't apear to work, I get 0 entries, actually I guess it could mean that there are no birthdays in the next 2 weeks, but how can I tell?
$info = mysql_query("SELECT Email FROM tblmembers WHERE DateOfBirth = DATE_ADD( CURDATE() , INTERVAL 14 DAY ) ");
03-14-2007, 01:15 AM
Nah doesn't work I made the interval 60 and still nothing...
03-14-2007, 01:44 PM
Only you have access to your database and therefore, only you can
troubleshoot that scripting problem. Really try hard to work it out.
Working on script bugs is a really good way to learn.
When you can display a birthday message and the user's email address
on your browser, let us know.