SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Send user an email on their birthday if you have their date of birth!

    Sounds simple but I'm not sure the best way to do it.

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php scripts are only executed when someone requests a page.

    you would need crontabs (a server funciton to schedule execution of certain scripts).

    then just query the database for any birthdays on the same day and send an email.

  3. #3
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how come things like vbulletin/phpbb have that and you dont need to set up cron for that.

  4. #4
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bumpety- any ideas except cron?

  5. #5
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may run the script every day, by yourself. Or put it as a back-end to an existing site, that's frquently visited.

    Hope that helps

  6. #6
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, assuming your Forum gets at least one hit a day, have a script check if a value in the db is set, and if it isn't, run the mail script and set the value, and if it is skip the conditional.

  7. #7
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylan B
    Or, assuming your Forum gets at least one hit a day, have a script check if a value in the db is set, and if it isn't, run the mail script and set the value, and if it is skip the conditional.
    Exactly

  8. #8
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cant gurantee every user visits forum once a day!

    thinking about it i dont think phpbb/vbulletin does actually mail ppl on their birthdays, it just displays birthdays in the stats which is a piece of piss.

    i reckon cron is the only way really

  9. #9
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't need every user to visit the forum once a day.

    But to have at least one visit a day to the forums index page

    And the mail comes into the user's mailbox on the right day.

  10. #10
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its not a forum its a web site so it will definately get a hit a day (not that i care its not my site ) but the end user wants birthday emails sent out

    im not understanding your logic remiya/dylan - please can you explain some more?

  11. #11
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put a secret IFRAME on the page locating the mailing script. On loading the page the script will be executed.

    Just check not to send email more than once

  12. #12
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No - I mean the logic of the script, how will you get it to only send the mail once...

  13. #13
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    store the date in the DB everytime it sends the emails, then everytime the script runs check to see if it was set sent the same day as today. if no, send it, if yes, return true!

  14. #14
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so i have to create a new table just to send a birthday message?

  15. #15
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Creating a new table isn't that big of a deal; it's better to have a bunch of smaller tables than one huge one.

  16. #16
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see your logic and it seems to work, thanks amigos.

    PHP Code:
    function birthdayCheck() {
    // check birthdays today and send message to members whos birthday it is, only if the birthdaycheck field in database is more than 24 hours before the current time

    $result mysql_query("SELECT birthdaycheck FROM birthdaycheck");
    $array mysql_fetch_array($result);
    $lastchecked $array["birthdaycheck"];
    $yesterday time()-1*24*60*60;

    if (
    $lastchecked $yesterday) {

    // check for birthdays today and send emails
    // write new last checked value

    }

    // end birthdayCheck() 

  17. #17
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way - can I improve my methods at all? I always query, fetch array and then get a value like that, is that how you guys all do it?

  18. #18
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dalechristian
    By the way - can I improve my methods at all? I always query, fetch array and then get a value like that, is that how you guys all do it?
    That's the only real way to do it.

  19. #19
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good - thought so!

    By the way, thought i hit a bit of a snitch because my members date of birth are stored in d/m/y format but then i realised i can just generate a d/m/y format of the current date and see if they match

  20. #20
    SitePoint Addict CasualNerd's Avatar
    Join Date
    Feb 2005
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recently had a birthday and I recieved nearly 20 emails from various forums (all vbulletin) and it really does remind you how much time you waste on forums
    Looking for people to post on an Adult forum.
    Must be cheap or willing to trade posts.

  21. #21
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I had to do this recently for an application I wrote. You are right - it is surprisingly difficult!

    The difficult part for me was working out how to calculate when a person's birthday is coming up, regardless of their date of birth.

    What format are the people's birthdays stored in? Does it include year of birth? Do you want advance notice of somebody's birthday or do you just want to know whose birthday is on a particular day?
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff


Bookmarks

Posting Permissions

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