1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MySQL Automatic email updates.

Discussion in 'MySQL' started by LapseOfSanity, Oct 8, 2013.

  1. #1
    Hey, I don't really know how to search for what I am trying to do. I have a MySQL database, its pretty simple as it just takes someones email address when they put it in and has a column for a timestamp when they did it. It is for newsletter type purposes, but my question is, what kind of code might I use to make my database or web site send me an automatic email whenever someone adds their email to the list and it updates my database? Right now I have to manually check it every time I want to see if there are more addresses on it, and I know there has to be an easier way. I don't know if you need my code, but if you do let me know and I will post it.
     
    Solved! View solution.
    LapseOfSanity, Oct 8, 2013 IP
  2. ironcladservers

    ironcladservers Well-Known Member

    Messages:
    389
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    115
    #2
    Shouldn't be a difficult task. There's a few ways to do this, but if you want some sort of instant e-mail being generated every time, then the best bet is to add an e-mail sending "function" in the same PHP script (or other type of interpreter) that adds the entry to the database, advising you that there's an update. You could go as far as to include variables from that PHP script in the e-mail function so that the e-mail notice that gets sent holds all the information you need, avoiding the need to manually log into the database to see the information.
     
    ironcladservers, Oct 8, 2013 IP
  3. LapseOfSanity

    LapseOfSanity Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Yea, I figured there was an easier way, but I am new to this SQL thing and I wasn't sure how to go about it, and I don't know how to word what I am looking to do in a google friendly way to narrow down the search results to that. It is written in PHP already, so I got that going for me so far.
     
    LapseOfSanity, Oct 8, 2013 IP
  4. #4
    Have you fiddled around with PHP scripting at all? All you should need is PHP's mail() function. That link should give you the basics of it, you would just need to look at your script and integrate it somehow so that everytime the particular PHP script adds something to the database, it also sends out an email.
     
    ironcladservers, Oct 8, 2013 IP
  5. LapseOfSanity

    LapseOfSanity Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Minor stuff. I have learned a ton about PHP over the last couple weeks. I am coming from working with just HTML/CSS to trying to make an interactive page with user accounts and SQL databases and all that PHP stuff. Lots of downloading templates and hacking them up and putting them back together how I want them to be, probably the most useful thing I have done lately. I usually stayed away from PHP because it is so hard to preview what I am doing before it goes live, but now that I have bought my own web space, thats not as intimidating since its my own project to screw around with. I am checking out the mail() function as we speak, hopefully I can make that work ^_^
     
    LapseOfSanity, Oct 8, 2013 IP
  6. LapseOfSanity

    LapseOfSanity Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Done, thank you for your advice ironclad. I just threw a mail() under the line of code that added the email to my database and added one of my own, and just like that I got an email from my website saying that my SQL database was updated. Thank you for the assistance and I am sure I will be posting here regularly with pleas for help as I take this project on now lol
     
    LapseOfSanity, Oct 8, 2013 IP