Creating a website – Part 8

Database Setup

We now have Xampp installed and can create the database. This is done in phpMyAdmin and can be reached by typing: http://localhost/phpmyadmin/ into the address bar of a blank browser tab. You will be asked to enter your username and password. The default for these is ‘root’ (without quotation marks). This will log you in and you will see a window similar to figure 1.0.

Tip: As you work through these articles it may be useful to install and use a separate browser. We’ve all been guilty at one point or another for having far too many tabs open and losing where a particular one is. Having a browser for just development will keep everything in one place allowing you to close and open everything with just a click. You also won’t require any plugins/extensions/addons as it will be used purely for local (offline) work.

phpMyAdmin screenshot
figure 1.0

You may see some information to the right of this showing some server information which can be helpful if you run into any errors, but in general can be ignored. It can be a bit intimidating seeing this for the first time however during this tutorial we won’t be using many of these options and settings.

First we want to click on the ‘Databases’ tab at the top. This is where we will give our database a name. As in figure 1.1, under ‘Create Database’, we want to type the database name in the field (in this case picaday) and click Create.

figure 1.1

We are then asked to create a table and put in the number of columns we require. Our first table will be the user table and needs 4 columns:

  • user_id
  • username
  • password
  • reg_date

The next screen looks a bit scary with four rows of fields to fill out, but we won’t be using all of them – just fill them out as I have as shown in figure 1.2. Some things to note are:

The user_id has the index PRIMARY selected from the dropdown box, and A_I (Auto Increment) has been selected. This means that every time a new record is created the user_id field is automatically filled in so we don’t have to worry about it ourselves.

Also the password column type is set to VARCHAR. I am only doing this to make it easier to test the different dummy accounts that we will be creating. Obviously putting up a live website that requires passwords you would never, ever, (EVER!) store passwords as plain text (this is the sort of issue that we will deal with in a later article).

The rest should be self-explanatory, so fill out/select as I have and then click Save at the bottom. You may have a window pop up when you select PRIMARY from the dropdown menu. Just click on Go to accept the defaults.

figure 1.2

Once you have clicked save, it will create the table and you will see a screen showing a similar layout as figure 1.3.

figure 1.3

Congratulations! You have created your first table in phpMyAdmin and can give yourself a thumbs up! In the next article we will set up the other three tables.

« Creating a Website – Part 7Creating a Website – Part 9 »