Reviewing sample PHP code that interacts with a MySQL Database Brad MarkleUpdated on August 16, 2021 2 Minute Read In our previous articles, we’ve created a simple website that allows for users to submit comments about an article. In this article we are going to walk through what happens when someone submits a comment in our test website. Step 1 – Look at the data currently in the database Before we post any comments to our database, we’ll want to look at our comments table to see what is in it. To do this: Log into your cPanel and click the phpMyAdmin icon Click your database in the left sidebar, and then click on your table. If you’re following our example, we’ll first click on “_mysite” and then “comments”. On the right side of the page, you’ll see all of the comments submitted. If you refer to our screenshot below, you’ll see we currently only have one comment, which is our test comment from a previous article: Step 2 – Submit a comment on your website At this point, we will replicate what a user will do, and that is leave a comment. To do this: Visit your first page, https://phpandmysql.inmotiontesting.com/page1.php?id=1. It is very important that “id=1” is in the URL, otherwise our php code will not know which article the comment belongs to. Input a comment and click submit (refer to screenshot below): The comment has been Posted to the server and we now see a confirmation, “Thank you for your Comment!”: At this point, we’ll want to run the test again, but this time on page2. Click the link on the page to go to page2.php and insert another comment. Step 3 – Confirm that your data has been written to the database Now that we’ve submitted 2 test comments, we should be able to see them in the database. Follow the same steps from “Step 1” above to view the new comments in the database: Now that we have comments in our database, we’ll show you in our next article how you can access the database and display those comments on each page. Share this Article Related Articles Submitting a Ticket Request How to Add/Cancel Domain Privacy in AMP How to Upgrade / Downgrade Your Hosting Plan in AMP How to Purchase or Cancel an SSL From AMP Manage Your Control Web Panel Server from the Account Management Panel (AMP) Advanced Product Support (APS) Explained Engrampa Archive Manager for Linux How to Change Your Domain Nameservers in AMP Adding a Dedicated IP Address to Your Server How To Get Great Support & Customer Service