Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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...

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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 ) ");

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Nah doesn't work I made the interval 60 and still nothing...

  • #7
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •