Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-13-2007, 05:32 PM   PM User | #1
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
Send Me An Email Of Birthdays

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?
tomyknoker is offline   Reply With Quote
Old 03-13-2007, 08:16 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Tomy ...

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.
mlseim is offline   Reply With Quote
Old 03-13-2007, 09:58 PM   PM User | #3
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
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...
tomyknoker is offline   Reply With Quote
Old 03-13-2007, 10:35 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.
mlseim is offline   Reply With Quote
Old 03-14-2007, 01:14 AM   PM User | #5
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
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?
Code:
$info = mysql_query("SELECT Email FROM tblmembers WHERE DateOfBirth = DATE_ADD( CURDATE() , INTERVAL 14 DAY ) ");
tomyknoker is offline   Reply With Quote
Old 03-14-2007, 01:15 AM   PM User | #6
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
Nah doesn't work I made the interval 60 and still nothing...
tomyknoker is offline   Reply With Quote
Old 03-14-2007, 01:44 PM   PM User | #7
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Tomy ...

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.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:18 PM.


Advertisement
Log in to turn off these ads.