The other day my pal Sam asked me how I managed the Fever notification sign-up page. He wanted to do something similar for a new project he’s working on. So I sent Sam my source code and we decided that others might benefit from this simple solution.
My sign-up pages usually have three states:
- The sign-up form
- The status message for subscribers
- The unsubscribe message for the dearly departed
All three states are served from the same page. Which state is displayed depends on an optional query string and the presence of a cookie.
Campaign Monitor provides a simple HTML form that you can copy/paste into your code and allows you to specify urls for custom subscribe and unsubscribe confirmation pages—which conveniently covers all three states. There’s even a Campaign Monitor Subscribers Pepper (created by Mark J. Reeves), which is handy if you’re Minted.
When you grab your form HTML from Campaign Monitor, set your subscribe confirmation page to the url of your sign-up page plus
?subscribed and your unsubscribe confirmation page to the url plus
Copy the sample PHP file below, fill with your own wit and beauty (taking care not to disturb the cookie setting and PHP conditionals) and get back to work on that not-so-secret-anymore project we’re all dying to learn more about.