Publishing Newsletter Using PHP & MySQL
Are you tired of using third-party tools to send out routine notifications and emails to your clients? Or, do you want to send your newsletters with individual names of people in the beginning. This series of articles helps you achieve this.
In the first article, you’ll learn to create an online subscription form that stores names and emails of people who want to receive your newsletter.
If you are hosting your website on a server that supports PHP and MySQL, through your control panel, you can access an area where you can create either a new database if it doesn’t exist, or create a new database. Most servers have the phpMyAdmin interface that lets you create and maintain database without having to learn MySQL commands. Even if you can’t make sense of the interface, try to locate a section that allows you to run SQL commands. Run the following command to create the new database:
CREATE DATABASE database_name
In place of “database_name”, use the name of your choice. In this case, I’ll use “newslet” so that we have:
CREATE DATABASE newslet
A single database can have many tables. Tables are logical structures that contain the rows and columns that store the data. Once our database is created, use the following command to create the table “subscribers”:
CREATE TABLE subscribers (
&nbps;s_name TEXT NOT NULL,
&nbps;s_email VARCHAR(255) UNIQUE NOT NULL)
This command creates the table with fields “s_name” (name of the subscriber) and “s_email” (email of the subscriber). We make the email field unique so that we don’t accept the same email again and again.
So our database is crisp ready to be used. In my next article, I’ll tell you how to create an online form that accepts name and email, perform a bit of validation, and then store the details into the database.