Create a custom comment section using PHP - PHP tutorial

Поделиться
HTML-код
  • Опубликовано: 15 авг 2024
  • 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 RUclips 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.

Комментарии • 145

  • @praveenprajapati4175
    @praveenprajapati4175 6 лет назад +1

    Sir, You are greatest teacher ever.

  • @timsideris8377
    @timsideris8377 7 лет назад +1

    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!

  • @godwinoluwadipe6098
    @godwinoluwadipe6098 3 года назад +4

    Good teaching, I appreciate you.
    Please can you complete the series this week?

  • @mackynikat8833
    @mackynikat8833 3 года назад

    . i really wanted to visit shindlers's hometown , i really honor that guy deep into my nerves , to put a stone on his tomb to show gratitudes . im aiming to be like him soon . and if we're going to talk about Phillipines sir . a $usd here cost around 54 pesos , and compared to walmarts workers , mall attendants here earn 14,088 pesos a month . average skill CSR about 18k per month and if walmart attendant earn €18 per hour convert it to 8 hours which makes it €1728 a month . you can say 1 peso bill is uquivalent to € 0.0001 . just saying that im going to guide you here sir . you can be the man here with my intelligence and wisefullness .

  • @convenientparking903
    @convenientparking903 7 лет назад +6

    when i did the SQL thing it gave me this error:
    A symbol name was expected! (near "date" at position 113)
    is there any way to fix this?

    • @npcDroneClass
      @npcDroneClass 4 года назад

      a lot of this code has been retired and won't work on modern browsers. there must be hundreds of tutorials on making a comment section for personal blogs/sites, none work, period. i followed another tutorial, ended up being a waste of time because on part6 in the series, the provided code is no longer valid. gotta wonder how any website makes comment sections these days. all those facebook knockoff comment sections have to have a source code somewhere...

  • @AaronEstebanSEO
    @AaronEstebanSEO 4 года назад +1

    12:50 you don't need to put the date, time, etc., into an input. You can just use plain php to write a date variable and send it straight into the database of when the comment was posted.

    • @rnomberg
      @rnomberg 2 года назад

      could you elaborate ?

  • @Cd5ssmffan
    @Cd5ssmffan 7 лет назад +6

    I'm getting a syntax error on the table "comments" on line 6 "A symbol name was expected! (near ")" at position 165)"

    • @Cd5ssmffan
      @Cd5ssmffan 7 лет назад +7

      Never mind, I fixed it by removing the comma on line 5.

    • @twl148
      @twl148 5 лет назад

      noided

  • @Pradeepkumar-gy4is
    @Pradeepkumar-gy4is 6 лет назад +1

    this video is awesome and please make a video on star rating system in php with MySQL

  • @anamikapatel983
    @anamikapatel983 7 лет назад +1

    good job....

  • @gautamkumarravi2870
    @gautamkumarravi2870 Месяц назад

    nice

  • @megaresh4912
    @megaresh4912 3 года назад

    u are a true god

  • @mackynikat8833
    @mackynikat8833 3 года назад

    10:46 i said to myself this is guy is a REAL GENIUIS!!!

  • @jhonny266
    @jhonny266 4 года назад

    excellent lesson, very good.

  • @mackynikat8833
    @mackynikat8833 3 года назад

    . and to someone who's just getting a first look in this comment , this is how you extract parse information out of a php statements in html tags /*

    • @mackynikat8833
      @mackynikat8833 3 года назад

      @@wibbuffey8485 sorry I forgot the d

    • @mackynikat8833
      @mackynikat8833 3 года назад

      @@wibbuffey8485 can you just apply the d . what just you creating ryt now ?

  • @daoudaibrahim1368
    @daoudaibrahim1368 7 лет назад

    bravo best teacher

  • @fanisdeli
    @fanisdeli 7 лет назад

    Tip: you can use double quotes IF you use single quotes on the echo. for example: echo ' ';

  • @leon1985ist
    @leon1985ist 5 лет назад +1

    Hi how are , any new ideas to do same thing but for 2019

  • @blexyt3485
    @blexyt3485 7 лет назад

    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,
    but
    Q:>/a real pwd in myphpadmin but another way to encrypt and decrypt pwd when password enter in page by user

  • @adamyoussef6880
    @adamyoussef6880 6 лет назад +1

    Hey, you're great! Thank you for sharing that. Can't wait to go for the next episode:)

  • @NirajDhakal
    @NirajDhakal 7 лет назад

    Really very helpful tutorial. Just everything is covered in this series. But i want latest comment a very top. Want your kind help...

  • @jha.gaurav
    @jha.gaurav 7 лет назад

    You make only one post/article what if there is more then one post/video/article . How can i get comments for more than a post, please reply , you are very good teacher and programme r

  • @MrGentlemanism
    @MrGentlemanism 7 лет назад

    Great man, thanks a lot!

  • @kudrah
    @kudrah 7 лет назад

    Excellent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @MrOxford24
    @MrOxford24 5 лет назад

    Really nice video, good job! Nic!

  • @albertgarcia6483
    @albertgarcia6483 7 лет назад

    nice videos sir! its very helpful.

  • @JagdeepSingh-or5ke
    @JagdeepSingh-or5ke 3 года назад

    I did exactly the same as you. Yet, the second closing tag of >? is being shown with the comment box in the output. Please Help!

  • @rizkyseptianto
    @rizkyseptianto 5 лет назад

    good

  • @mediastreamer-24
    @mediastreamer-24 6 лет назад

    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?

  • @markuslanggeng
    @markuslanggeng 3 года назад

    is this also an example of crud system?

  • @rodrigopineda2337
    @rodrigopineda2337 2 года назад

    hi how are you? so i am going through your videos because i just created my website and i want a comment section where people can rate my service. I have a question regarding this, do they need a log in to be able to insert their names? or is it possible without it?

  • @cygnus540
    @cygnus540 6 лет назад

    When i wrap the form in the php tag after the button on the page it shows ";?>

  • @oba-joshuasamuel8293
    @oba-joshuasamuel8293 4 года назад

    Please how can I create a cms that I can use to update both media files and text contents on my website. Thanks

  • @sanjayn7029
    @sanjayn7029 4 года назад

    Thanks a lot

  • @cadeaulucmann1949
    @cadeaulucmann1949 6 лет назад

    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?

  • @jayaruban8534
    @jayaruban8534 6 лет назад

    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

  • @yoursspecial9280
    @yoursspecial9280 5 лет назад

    NICE

  • @mackynikat8833
    @mackynikat8833 3 года назад

    . and the way you look sir . your charm . with that saying this with confident we can make a fortune out of that . me myself you already deserved a kiss ...

  • @StanleySK
    @StanleySK 7 лет назад

    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

  • @ArrayBuffer
    @ArrayBuffer 7 лет назад

    good tutorial

  • @rajeev6843
    @rajeev6843 7 лет назад

    bro you are life saver!!!!!!!!!

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +1

      Thanks

    • @rajeev6843
      @rajeev6843 7 лет назад

      Bro can you suggest any idea or project that i can take up as my under-graduation project .
      I need to execute and present it to my professor at the university.

    • @globaldevelopernetwork4435
      @globaldevelopernetwork4435 7 лет назад

      Just recreate a mini instagram or twitter?

    • @aseemlalfakawma5084
      @aseemlalfakawma5084 7 лет назад

      something like google keep, which saves notes and all, with login, etc.

  • @bundas2011
    @bundas2011 4 года назад +1

    can you create a download link for the code part?

    • @leoawara
      @leoawara 3 года назад

      Yes, I am also looking for that. Were you successful in finding that?

  • @gabrielfono844
    @gabrielfono844 3 года назад

    is this course still relevant in 2021?
    I have learnt most my thing through his course since a year and half.
    I look forward to hearing from you back Mr krossing

    • @Dani_Krossing
      @Dani_Krossing  3 года назад +1

      No hehe. Always go for my courses that has a image of me on it (you can find it on my channel page). That one you commented on is quite old, and I should probably take it down 🙂

  • @mr.blue7357
    @mr.blue7357 4 года назад +1

    You kinda sound like @LieLikesMusic

  • @exo7655
    @exo7655 6 лет назад

    so... When i try to type in the date and time up at the top all i get is it shows me the line of code but when I remove it it's fine I just dont understand....

    • @sanjayn7029
      @sanjayn7029 4 года назад

      You can use this code:
      date_default_timezone_set('America/Santiago')
      This has the same time zone as Maryland

  • @akshaydeogaonkar7120
    @akshaydeogaonkar7120 3 года назад

    Does it need a database?

  • @hellafresh4520
    @hellafresh4520 8 лет назад +2

    is it possible if you can do video on how to create an upload only images with the comment section? For example, posting images on website with image descriptions and where others can comment those images?

    • @Dani_Krossing
      @Dani_Krossing  8 лет назад

      Similar to 9gag or memedroid?

    • @hellafresh4520
      @hellafresh4520 8 лет назад

      similar to Instagram! The photo on top and then comment down below!

    • @Dani_Krossing
      @Dani_Krossing  8 лет назад +1

      There have been a couple other requests as well but I'll try and get to it as soon as I can :)

    • @hellafresh4520
      @hellafresh4520 8 лет назад

      Thanks man! I appreciate all your hard work, in making these videos for us to learn!

  • @fariazkhan1779
    @fariazkhan1779 6 лет назад +1

    Whenever I am refreshing the page, the data gets re-inserted.
    Can you please tell me how to get rid of this?

  • @rockface9269
    @rockface9269 7 лет назад

    Hello,I feel as though it would be appropriate to describe a database you can use for this and how to set it up.

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +2

      If you go back in my PHP playlist I have shown in detail how to set up a phpmyadmin database and what it is :)

  • @Ginfio
    @Ginfio 3 года назад

    wait, you never showed us how to display the comments.

  • @SlowEasyEnglish
    @SlowEasyEnglish 7 лет назад

    I'm not sure if the answer should be obvious to me but at 11:40, you didn't say why you chose to wrap the form in PHP tags. Just wondering why because if I sat down to do this myself, I would never think of doing it that way on my own.

    • @turboromy
      @turboromy 7 лет назад

      Maybe you figured it out already, but in case not, that form section will become visible/invisible depending whether user is logged in later on the series. There should be no difference within this video.

    • @dunnearbell
      @dunnearbell 6 лет назад

      he put it in php because earlier he used php for the time Copenhagen/.... something. so to recall that date time in the "date" field of the form, he needed to put the form in php...
      i think. im just learning as well.

  • @nvandermark3517
    @nvandermark3517 6 лет назад

    What is that lettertype u using?

  • @quakepie6627
    @quakepie6627 5 лет назад

    thank you for the lesson really helps us.

  • @drezcovers1113
    @drezcovers1113 7 лет назад

    love your teaching style, subscribed :)

  • @jggamingYT
    @jggamingYT 7 лет назад

    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?

    • @SimicMateja
      @SimicMateja 7 лет назад

      id = user id
      uid = username (example: Jelmer55)

  • @zgong9919
    @zgong9919 7 лет назад

    My comments don't go in the order they are posted, they go in the middle alot of the time. Would this maybe be because i didn't have the datetime thing becuase i didn't want it? and is there any way to sort them by id in phpmyadmin or when reading out the database entries.

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад

      Hi there! You could use "ORDER BY id" instead of by date. But if you are making a comment system I think it is VERY important to have the date registered in the database. Even if you are not planning on showing the date inside you website, it is still important to have data that you can use for other purposes such as deciding the order you want to show posts on a site :)

  • @atvoriginals
    @atvoriginals 4 года назад

    India✋

  • @Enopocalypse
    @Enopocalypse 8 лет назад

    How would you write the code to say how long ago the comment was posted instead of what date the comment was posted (Similar to how RUclips does it)?

    • @Dani_Krossing
      @Dani_Krossing  8 лет назад

      +Cheeky_Tree
      Then you would need to write a PHP script that counts the time between the date that is registered within the database and the current date. And if you want it completely authentic to how RUclips does it, round up the time depending in how long ago it was posted.
      If I get the time I will show how to do this as well.

    • @Enopocalypse
      @Enopocalypse 8 лет назад

      So the registered date would be kept in seconds? I don't know if this would be correct or accurate at all, but when I researched it, this is the example that I could find which made the most logical sense.So would you say this is the sort of script that I would need:
      $calc_times[] = array('Year', 'Years', 31557600);
      $calc_times[] = array('Month', 'Months', 2592000);
      $calc_times[] = array('Day', 'Days', 86400);
      $calc_times[] = array('Hour', 'Hours', 3600);
      $calc_times[] = array('Minute', 'Minutes', 60);
      $calc_times[] = array('Second', 'Seconds', 1);
      Or something along those lines as long as it is in an array
      Then I would need a foreach loop going through and checking what it would be named?

    • @Dani_Krossing
      @Dani_Krossing  8 лет назад

      +Cheeky_Tree
      You are on the right track, I would do something like this:
      date_default_timezone_set('Europe/Copenhagen');
      $timePosted = strtotime('2016-01-19 18:20:20');
      $timeCurrent = strtotime(date('Y-m-d H:i:s'));
      $getSeconds = $timeCurrent - $timePosted;
      $getTime = array(
      array('Second', 'Seconds', 60),
      array('Minute', 'Minutes', 3600),
      array('Hour', 'Hours', 86400),
      array('Day', 'Days', 2592000),
      array('Month', 'Months', 31104000),
      );
      if ($getSeconds < $getTime[0][2]) {
      echo $getTime[0][1];
      } elseif ($getSeconds < $getTime[1][2] && $getSeconds > $getTime[0][2]) {
      echo $getTime[1][1];
      } elseif ($getSeconds < $getTime[2][2] && $getSeconds > $getTime[1][2]) {
      echo $getTime[2][1];
      } elseif ($getSeconds < $getTime[3][2] && $getSeconds > $getTime[2][2]) {
      echo $numDays.$getTime[3][1];
      } elseif ($getSeconds < $getTime[4][2] && $getSeconds > $getTime[3][2]) {
      echo $getTime[4][1];
      }

  • @scsv8525
    @scsv8525 2 года назад

    but... where the comments go?

  • @MechaGriffin
    @MechaGriffin 6 лет назад

    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.

    • @Dani_Krossing
      @Dani_Krossing  6 лет назад

      GamerGriffin If you start at the beginning of my PHP playlist, then I will show how to get started ;)

    • @MechaGriffin
      @MechaGriffin 6 лет назад

      mmtuts Alright, I'll give it a look, thanks for the reply!

  • @LuigiCotocea
    @LuigiCotocea 5 лет назад +2

    Part 2 pls!

  • @funwithalbi2425
    @funwithalbi2425 2 года назад

    src? pls

  • @galvinleven7550
    @galvinleven7550 5 лет назад

    gud

  • @vladimirputin5658
    @vladimirputin5658 7 лет назад

    Can I ask you where did you studied???

  • @eugenedonato5688
    @eugenedonato5688 4 года назад

    Sir, can you please make a video on how to upload a website to the internet. Thank you very much. :)

  • @beebuwear
    @beebuwear 6 лет назад

    I am new here, please how do i get the source code?

  • @blexyt3485
    @blexyt3485 7 лет назад

    Advise_Or_Contr:>/
    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....
    }

    • @mahohiyajo
      @mahohiyajo 7 лет назад

      || == OR not AND, AND == &&

  • @kurdistanregion6592
    @kurdistanregion6592 6 лет назад

    where are the patron files? :)

  • @andya6569
    @andya6569 7 лет назад

    What software did you use for the screen capture ?

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +3

      I found Bandicam to be the best one for desktop capture. But I'm also using an uncompressed codec that can be downloaded for free called Largerith Lossless, which is compatible with Bandicam. Lossless gives the highest quality video, but also takes up a lot more space when you record.
      I have a video here on how to set up Largerith Lossless with Bandicam if you are interested: ruclips.net/video/T66cGD7nMko/видео.html

    • @andya6569
      @andya6569 7 лет назад +1

      thanks bro you just gained a subscriber

  • @diogogaspar68
    @diogogaspar68 5 лет назад

    So after the button there are these characters ?">, what do I do.

    • @diogogaspar68
      @diogogaspar68 5 лет назад

      Actually "; ?>

    • @Jonny9403
      @Jonny9403 5 лет назад

      @@diogogaspar68 Same problem. I'm not a pro, i just need those structures for a little basis but can't even open the php file, nor do I understand those guys talking about installing "php". What is there to be installed? It just works for me, when I name the file .html, but then there occur the endings ";?>
      Crazy stuff.

    • @SirZyPA
      @SirZyPA 4 года назад

      @@Jonny9403 thats why you install xampp, so, php is a server side programming language, and it requires you to compile it, html is a markup language, and every browser automatically compiles your markup thats why html works for you, and php does not.
      Google xampp and download it, then open the program, start your apache and MySQL server, then go to "c:/xampp/htdocs" and put your files there, then when you want to open it, open your browser and in your url navigator, write localhost

  • @nishatrabbi
    @nishatrabbi 5 лет назад

    sir can you tell me where can I see those submitted comments?

  • @KimKongKun1337
    @KimKongKun1337 6 лет назад

    Have you bought Sublime Text?

    • @YoureHot
      @YoureHot 6 лет назад

      You don't need to buy that.

  • @raypist1524
    @raypist1524 7 лет назад

    you never showed how to include the css into the php, and i'm new to all of this.

    • @raypist1524
      @raypist1524 7 лет назад

      Ah thank you so much, I've been racking my brain for a week!

  • @jackfrost8969
    @jackfrost8969 5 лет назад

    include this in a playlist

    • @Dani_Krossing
      @Dani_Krossing  5 лет назад +1

      No this video has a lot of bad programming habbits in it. It is still a good "guide" which is why I haven't taken it down yet, but it is not a secure way to create a comment section using PHP.

    • @jackfrost8969
      @jackfrost8969 5 лет назад

      @@Dani_Krossing then can you plz make a new video. this comment series didnt even work for me.

  • @johnjordandionisio9402
    @johnjordandionisio9402 6 лет назад

    Can someone help me i cant style the textarea and button basically all the elements inside the "echo"

    • @musiclibrary4706
      @musiclibrary4706 6 лет назад

      maybe you didn't link your css file to your html ..
      rename your css file "style.css" and put this code inside your tag

    • @johnjordandionisio9402
      @johnjordandionisio9402 6 лет назад

      rolly asuncion i did, cause i try styling other elements and it work just fine

    • @equasezy
      @equasezy 5 лет назад

      did you solve it?

    • @equasezy
      @equasezy 5 лет назад

      just made a class called .textarea instead of just calling textarea{} and it worked.

  • @Solitide
    @Solitide 8 лет назад

    the date time doesn't work for me. i get the time 0000-00-00 00:00:00 everytime

    • @Solitide
      @Solitide 8 лет назад +1

      i fixed it .. forgot the
      $date = $_POST['date'];
      haha

    • @hitfromcs
      @hitfromcs 8 месяцев назад

      @@Solitide still helpful after 7 years! Thanks

  • @sympathycapture9233
    @sympathycapture9233 5 лет назад

    am getting error in my sql

  • @TechMechMaster
    @TechMechMaster 6 лет назад

    plz send code

  • @sympathycapture9233
    @sympathycapture9233 5 лет назад

    CREATE TABLE comment()
    cid int(11)not null AUTO_INCREMENT PRIMARY KEY,
    uid varchart(128) not null,
    date datetime not null,
    message TEXT not null
    );

  • @byreaper8992
    @byreaper8992 7 лет назад

    Why is your webspace so fast? :( I have much longer waittimes than you.

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад +1

      I'm using XAMPP to work on a local server, not an online server which makes it faster.
      Also, trying not to make this sound braggy, I also have a high end PC which makes it faster since the server is on my PC and not online :)

    • @byreaper8992
      @byreaper8992 7 лет назад

      I have it also on my pc, but with IIS from Microsoft.. thanks for answer.

  • @ArrayBuffer
    @ArrayBuffer 7 лет назад

    ur color scheme name please

  • @miataylor16
    @miataylor16 4 года назад

    Hi Dani, am I able to make WordPress Plugins for my website if I learn PHP? I got a web hosting plan with lightyearhosting.com/ and built a blog, and I'd like to make my own plugins. :) Is it hard?

  • @soniaprajapati5248
    @soniaprajapati5248 Год назад

    php

  • @snø_music0
    @snø_music0 6 лет назад +1

    im getting a syntax error unexpected 'date' (T_STRING), expecting ',' or ',' in C:/xamp etc. any suggestions? my code is exactly as yours is

    • @adampetersson6809
      @adampetersson6809 6 лет назад

      Did u get the whole system to work or is it outdated?