11.1. Adding an admin Table to the Database

Enabling administrators for your site requires that you create a table to store their information. This simple table, admin, stores the following information:

  • username: The administrator's login name

  • password: The administrator's password

Your username needs to be unique, so make it the table's primary key. Specify both fields as of the VARCHAR type, limit the username to 75 characters, and limit the password to 40 characters.

To create the admin table, navigate to http://localhost/phpmyadmin in a browser and open the SQL tab. Enter the following command to create your table:

CREATE TABLE simple_blog.admin
(
username VARCHAR(75) PRIMARY KEY,
password VARCHAR(40)
)

Get PHP for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.