InMotion Hosting Support Center

In this tutorial series, we are going to create a website at This website is going to have 2 pages, and each page is going to allow for comments.

When users submit a comment, we'll want to keep track of the following information:

  • Their name
  • Their email address
  • Their website
  • Their actual comment
  • The time the comment was submitted

In order to keep track of this data, we need to:

  1. Create a database for our website
  2. Create a table in the database that has values for name, email, website, and comment.

Step 1. Creating a Database

The easiest way to create a database is to use the MySQL Database Wizard available in cPanel. This will not only create a database for you, but help you create a database user and assign the user privileges to your database. For more help with creating a database, please see How do I create a MySQL Database in my cPanel?

If you're following along with our example, we've used the MySQL Database Wizard and:

  1. Created a database named inmoti6_mysite
  2. Created a database user inmoti6_myuser with a password of mypassword
  3. Assigned inmoti6_myuser with privileges to inmoti6_mysite


Step 2. Creating a Table

Now that we've created our database, we need to create a table to hold all user comments. This table will be called "comments". To create this table:

  1. Log into cPanel and click the phpMyAdmin icon
  2. Select your database in the left menu. (we clicked on "_mysite" because our database is "inmoti6_mysite")
  3. On the right side of the page under "Create new table on database", enter "comments" as the name and 7 as the number of fields and click "Go"
  4. On the next screen, we will need to fill in specific details for our table. Please use the screenshot and details below to create the table

    Field: id
    Type: INT
    A_I: (put a check in the box)
    To help manage individual comments, for example to delete one, we want to assign a specific id number to each comment.

    Field: name
    Type: VARCHAR
    Length/Values: 60

    Field: email
    Type: VARCHAR
    Length/Values: 60

    Field: website
    Type: VARCHAR
    Length/Values: 60

    Field: comment
    Type: TEXT

    Field: timestamp

    Field: articleid
    Type: INT
    Each comment needs to belong to a specific article, otherwise we wouldn't know which comments to display for which pages.


  5. After you have filled in the details above, click "Save"

Congratulations, as this point we have successfully created our database and setup our table! In our next article, we'll show you how to create a form using HTML that asks the user for their comment.

Was this article helpful?
Continued Education in Course 205: Using PHP to create dynamic pages
You are viewing Section 2: Setting up a Database to Handle Form Data
Section 1: How to Create a Custom PHP Contact Form with Validation
Section 3: Creating a simple HTML Form to get user comments

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

n/a Points
2017-08-16 6:00 pm

Hello. I have a problem with the article id. So we added articleid field to the database but how do I assign my pages ids? For example, I have 3 pages and I want their article ID's to be respectively 1,2 and 3. But how do I do that? Do I have to add that to the database or my pages codes? Because I cannot figure out how to do it, I keep getting the error "invalid article id". I would really appreciate your help since this is my ITGS project and I have to finish it as soon as possible.



3,856 Points
2017-08-16 6:52 pm

Thank you for posting your comment. I'm sorry to see you're experiencing issues with the articleid in your form. The articleid is detected by the link the comment is being posted on. To resolve this, you would need to configure your links to be formatted like so:

If the URL does not contain the "?id=#" portion, you will continue to experience errors. You would simply need to configure those URLs as the links to your comments pages. As long as those are included in the URL, then upon submission, the articleid can properly be identified and passed correctly to your database. I hope this helps!

Carlos E
n/a Points
2017-05-31 2:32 am

Thanks for works for me

n/a Points
2016-06-22 5:05 am
Hi, I got one problem. How do you configure your website to add data to your database. For instance if someone signs up to my website, how can i take whatever data he puts in to my database so that it can be retrieved when they wanna login
42,943 Points
2016-06-22 10:36 am
Hello Sabelo,

You're asking for code for your website. Unfortunately, we don't provide coding support but you may be able to use the information provided in this tutorial on using PHP to add data. Otherwise, we recommend that you work with a developer or programmer.

If you have any further questions or comments, please let us know.

Arnel C.
n/a Points
2016-01-24 2:46 pm

Thank you guy's very much! This was very

helpful and as someone said, in my own words, PICTURES in tutorials ROCK!

Thanks again, Scott

n/a Points
2015-02-22 8:36 pm

Hey, how does that work, can I use a plugin to wp to this?

42,943 Points
2015-02-23 11:29 am
Hello Hais,

Thanks for the question. Yes, there are many form plugins available on WordPress that can make this process much easier. Please go to and do a search in their plugins section for further details.

Kindest regards,
Arnel C.
n/a Points
2015-01-22 12:37 pm

Web development isn't that dificult with resources like this available.

n/a Points
2015-01-22 12:35 pm
Nothing to improve! It's straight to the point and very helpfull.
n/a Points
2015-01-20 6:03 am


This is my website, please guide me it's working fine, but the issue is, mail is not coming in proper format, I want to get the mail from any enquiry in table format.

How does it possible. Please guide me.. 

Many Thanks in Advance


11,186 Points
2015-01-20 9:24 am
To clarify, do you want the contents of the message itself to be within a table? To do so, you would need to create a table within your code and dynamically insert your field content with PHP. We cannot provide exact code to do so, but that should give you the general idea of what you need to do.
n/a Points
2014-10-15 4:20 pm
Looks A-OK to me
n/a Points
2014-09-23 5:53 am

I doubt I can just set them as an admin and myself as a subscriber and be done with it,

31,595 Points
2014-09-23 9:16 am
Hello asiskumar,

Thank you for contacting us. Indeed there is most likely more to the setup. We are happy to help with any specific questions, or steps you are having problems with.

This guide is part of our full class on Using PHP to create dynamic pages.

If you have any further questions, feel free to post them below.

Thank you,
2013-08-22 3:26 am
Hi Brad,
Thanks for the share, and actually I was really impressed with the way you made it look so simple with all those pics! I was just about to hire some web developers for this task and here your blog came to my rescue and saved me some bucks :).

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

16 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!