I am trying to write a small PHP script for managing subscriptions for a mailing list. I was trying to find whatever resources I can find over the internet but I only came up with:
- Very simple PHP scripts with only single opt-in or “fake” dual opt-in features.
- Very complicated multi MB PHP projects, like PHPList (7.8 MB!)
With “fake” dual opt-in I call methods which either put the email address as the validation string, or what uses cookies in the browser.
All I would like to achieve is:
- Someone can write it’s email address in a PHP form and click submit
- He receives an email with an URL where he needs to click. The link should not contain the email address but some md5 or random string
- Once clicked on the URL he gets to a page which shows “email confirmed”
On the server-end the addresses could be save in a text file in a protected folder or if you believe it’s really important to keep them in a database then in a database.
My questions so far are:
- Could someone guide me to some tutorial or write-up about how to write such a script
- Whether I should use database or a simple file. All I would need is to insert simple lines of new emails with the possibility of duplicate checking.
- How to store the temporary id-s for the double opt-in system. I thought about using something like
md5 ("email" . "passphrase")for the id generation and storing them next to the email addresses.
Just for the fun of it, here is a pretty indepth example. It should be easy to grasp what’s going on in there and why.
Caveat: Code hasn’t been tested so syntax and other errors are possible.