Create a custom comment section using PHP - PHP tutorial

Create a custom comment section using PHP - PHP tutorial
Create a custom comment section using PHP - Learn PHP backend programming. Today we will create our own comment section from scratch using PHP.

We will create everything including the database, the HTML, and the PHP. With this we will allow users to create comments, edit, and delete their comments.


mmtuts is a YouTube channel that focuses on teaching beginner and advanced courses in various multimedia related skills.
We plan to make tutorials available on programming, video production, animation, graphic design, and on software such as the Adobe Creative Cloud programs.

PHP for beginners is a how to series that teaches the PHP coding language to people who are just starting out learning programming. The course teaches how PHP scripting can be made easy and teaches how to build many apps such as a login system, a comment section, how to upload images, how to create users in a website, and much more. Creating dynamic websites with PHP is easy and should not be seen as otherwise, which is why we want to explain the language in a easy to understand way for beginners.

If you have suggestions on new courses, or specific lessons within existing courses you would like to see, then feel welcome to submit them in the comment section or in a private message. ALL suggestions will be seen, but not all will be replied to since we get quite a few every day.

RRelated Posts

Why I Left My $100,000+ Job at Google

Here’s why I left Google and why I am NOT following my passion! :P Keep in touch on Facebook: https://www.facebook.com/entercsdojo Support me on Patreon: https://www.patreon.com/csdojo My

Dynamic Page Creation: PHP

http://technotip.com/279/dynamic-page-creation-php/ In this PHP program we will not be generating pages, but creating the illusion of dynamic page creation! i.e., we will have a bunch of files


  • Joshua Texon
    thank you for the lesson really helps us.
  • anderson cris
    Are you out there and don't know in which program to invest your money and get a high returns within few days? We have one of the best service that guarantee high returns. Kindly get back for more info today if you are interested in learning more about our services newlifeinvestement@gmail.com .
  • Jack Frost
    include this in a playlist
  • Galvin Leven
  • cygnus x1
    When i wrap the form in the php tag after the button on the page it shows ";?>
  • Jaya ruban
    i was made a comment section on my cpanel, but it doesn't work. It's showing an " is currently unable to handle this request.
    HTTP ERROR 500" this error. how to fix it
  • Praveen Prajapati
    Sir, You are greatest teacher ever.
  • Tech Mech Master
    plz send code
  • John Jordan Dionisio
    Can someone help me i cant style the textarea and button basically all the elements inside the "echo"
  • Adam Youssef
    Hey, you're great! Thank you for sharing that. Can't wait to go for the next episode:)
  • Reaber Saadi
  • CADEAU Lucmann
    ok hum that's all for the comment section? i thought it was a big deal so i just need to create a table for these contents nd select them from this table to be published in my php page.... Will user see the comment of each other if i do it this way?
  • Kurdistan region
    where are the patron files? :)
  • الحسين الادريسي الهاشمي
    ur master i need to teach as how to make profile comment like dashboard
  • Reflexez
    Is this a similiar process if you want to have a "blog" style article/news section on your website, where it loads recent articles into the <body> of your index.php page? I don't want to keep hardcoding <p> paragraphs of text</p> on my index.php to make a blog because it gets super huge and ugly obviously. I figured you could use a method to display the most recent articles on your main page , like an integer value <5 so you don't get like 20 blog posts on the main page too. Is PHP the best to do this?
  • Fariaz Khan
    Whenever I am refreshing the page, the data gets re-inserted.
    Can you please tell me how to get rid of this?
  • Cutes Looks
    I am new here, please how do i get the source code?
  • Pradeep kumar
    this video is awesome and please make a video on star rating system in php with MySQL
  • Haymkarran S Bhalla
    Hi buddy. With all your help and a little guidance from other fellow YouTubers, I was able to create my commenting system. Kindly have a look - https://haymkarran.com/comments.php
  • Shawn Tompke
    If it doesn't work for you, repeat the whole process and find your error. It is PROBABLY due to the fact that you missed even one simple character.

    For instance at the very beginning i wrote "messge" instead of "message" and it wouldn't post comments.

    I'm sure you'll get it working if you overlook every bit of text you wrote.
  • gigawatt
    Out of interest, I am using a login system that has one database linked with it, with a table. So for a comment section to work with this, so a user account has a comment box to post to an index page of that user, that requires a database for those comments, not just another table using that first database?

    As how that works out with a comment box once logged in, and and then posting a comment, that I don't know how to do. I imagine this tutorial could be the answer to get some of this task done. I'll return to try this out. Another database?
    please i need to do this using AJAX and Jquery but my problem is how to pass the comment id and comment text
    from my submit button and textarea respectively to jquery then to the php validation but my code only recognises the comment id (id of the image i want to comment on) without catching the text in text area here is my code : $(".comment1").click(function(event){
    var submit1 = event.target.id;
    var text1 = $("#comment1").val();
    comment: text1,
    commentbtn: submit1
    text1 ="";

    }); where .comment1 is my submit button class with its id as id of the image, and #comment as the id of my textarea.
    please help me, i need it urgently thanks alot.
  • Exo
    so... When i try to type in the date and time up at the top <?php
    date_default_timezone_set('United States/Maryland')
    ?> all i get is it shows me the line of code but when I remove it it's fine I just dont understand....
  • NotaBot
    CSS didn't work
  • GamerGriffin
    Hello mmtuts!

    Do you have a video where you show the installation of PHP? I want to make sure when I follow your tutorials, there won't be any error due to incorrect installation or a missing installation.

    If you respond, I would be absolutely overjoyed.
  • Hadi Haider
    this is going to submit comment to one article, what if we have multiple articles, all articles will have the same comments! , what is the best way to have a single comment for each article?
  • TantrumSlayer69
    Have you bought Sublime Text?
  • Nilark
    What is that lettertype u using?
  • owen sziber
    Dude, these are all great videos. I am a student learning PHP, and this is the only youtube videos that are helping me pass at this point. How many videos do you have on PHP?
  • lil trap
    im getting a syntax error unexpected 'date' (T_STRING), expecting ',' or ',' in C:/xamp etc. any suggestions? my code is exactly as yours is
  • Vladimir Putin
    Can I ask you where did you studied???
  • Albert Garcia
    nice videos sir! its very helpful.
  • cd5ssmffan
    I'm getting a syntax error on the table "comments" on line 6 "A symbol name was expected! (near ")" at position 165)"
  • daouda ibrahim
    bravo best teacher
  • Ray Pist
    you never showed how to include the css into the php, and i'm new to all of this.
  • miralihyder talpur
    thank you help me lot
  • StanleySK
    please help me, i don't have full message from comment in comment-box, i wrote a long line of text and they are no paragraphs, it write me only one line of text out of the box
    good job....
  • hiren vaishnav
    hello nilson,
    i need help out of ur limit ,
    i don't think you are fail,
    but contact me as fast as possible...

  • hiren vaishnav
    in your previous video " Create error handling for PHP login " cross checking first, last, uid, and pwd.
    we can you || or AND conditions for empty error handling
    exp:>? if ( empty ( $first ) || empty ( $last ) || empty ( $uid ) || empty ( $pwd ) ){
    //same code as what you want....
  • hiren vaishnav
    hello dear,
    you are my impression and teacher also,
    thank you for all,
    and thanks to internet and youtube to possible this
    Q:>/ which text editor use to PHP,
    -->in your previous 'PHP hash ' video
    encrypt pwd and enter in myphpadmin, right,
    Q:>/a real pwd in myphpadmin but another way to encrypt and decrypt pwd when password enter in page by user
  • Niraj Dhakal
    Really very helpful tutorial. Just everything is covered in this series. But i want latest comment a very top. Want your kind help...
  • king world
    Good job
  • E
    good tutorial
  • E
    ur color scheme name please
  • TheAmaz1ngBurger
    Tip: you can use double quotes IF you use single quotes on the echo. for example: echo ' <textarea name="comment"></textarea> ';
  • Jelmer
    You use varchar(128) for your uid, but is it also possible to use int(11).
    Because you are using "user id" and not "username" am I correct?
  • Tim Sideris
    Thank you very much. My mother is from Denmark, so it was nice to learn from your accent. Maybe you know my cousins. Excellent training videos, thank you very much!