How to make a comment form in HTML & PHP

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • New version of this video: • UPDATED VIDEO How to m...
    Как се правят коментари в сайта на HTML и PHP
    Как сделать комментары в сайте на HTML и PHP

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

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

    I've made a new improved version (2016) of this video (2013): ruclips.net/video/0KwnPS5OhGI/видео.html
    Fixed:
    New comments are on the top
    No undefined variables
    Please watch the new video!

  • @peacefulbutters5561
    @peacefulbutters5561 9 лет назад +2

    Thanks a ton this is the only tutorial of this variety as far as php comments go. I'm using this as the basics for my forum I'm making for some friends and I to use. Much appreciated you are awesome.

  • @bensosfrequents
    @bensosfrequents 10 лет назад +1

    This guy has done a great JOB the concept here is your ability to write to the external file and then display what you have written to the file.. So if you were using database you cold first write a PHP program to post data to the file. Then use mysql_fetch_assoc() or mysql_fetch_array(). To display back what have posted in data base. Then a caution should be take to avoid website attacks and Database injections....... So thanks very much sour cherry

  • @Rockybaikalov
    @Rockybaikalov 2 года назад +1

    Wow, this was 8 years ago. But still very useful ! Or I can even say that this is one of the most useful video ever !

    • @user-so1jm4ck4g
      @user-so1jm4ck4g 2 года назад

      I think its better to do comments system with mysql

  • @Amiduphiri-mr8es
    @Amiduphiri-mr8es 3 месяца назад

    You are a legend man❤❤

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

    How to keep the comments updated in every 1~3 seconds? I mean how to make it a real time comment box?

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

    i loved your comment staff you did from beela dowd i live in los banos

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

    You need to INSTALL A LOCAL WEB SERVER to run PHP scripts! Otherwise PHP will display as plain text. The local web server makes an environment like on a web host, so you can run scripts like PHP that use servers to process the data. But languages like HTML, CSS and JavaScript don't need one.
    PHP won't work without a web server!
    Good local web servers are:
    XAMPP - www.apachefriends.org/index.html
    Денвер - www.denwer.ru/
    WAMP - www.wampserver.com/en/

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

      no wander mine doesnt work. so thankful that i ran to the comment section and found this haha. bet im still re typing the codes for a million times if havent read this. thankss

  • @lelouchzero7
    @lelouchzero7 9 лет назад +2

    can someone please help me, i need a code or tutorial about editing the comment

  • @sujanacharya2084
    @sujanacharya2084 6 лет назад +2

    hey can you help me make school project ...
    its too hard for me cause i was absent when the chapter html was taught.And the big problem is recently our computer teacher has been changed.I just don't know how to make one i would become fail if i don't make one.Please !please!! help me :( :(
    i have to submit it within 3 days.
    please help me

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

      Sujan Acharya lol I know this is from 2 years ago but html isn’t that hard to learn. I learned html and css in a day and can code a website in my sleep

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

      @@blutoo2155 really wtf can u teach me lol

  • @automrphpsytrancemusicproj2655
    @automrphpsytrancemusicproj2655 2 года назад +1

    Hello there, this is such a great Tutorial indeed, thanks alot for sharing !!! Now, quick question please : What is the exact location of the com.txt file ? in the / directory ? elsewhere ? CHEERS !

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

    Nice

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

    Fatal error: Maximum execution time of 20 seconds exceeded in /home/vhosts/web-sajtovi.eu5.org/1/index.php on line: echo fread($read, 1024);
    How solved?

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

    u're a legend

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

    Thank you so much.

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

    I am in Notepad ++. Did the code "perfect" as shown in the video. It is not working. It shows the comment bar, but everything under the /?php tag shows in as pure code. What language do I use? I am using html. I even saved it as index.php. What do I do?

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

      php is a web based script or sever side script which the user should not be able to see the php codes. so just installing note+ will not help u so download php and run such like C:\php\php.exe myfile.php.

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

      you want to connect with Sql for data storing or retrieving just set up a local server. download wamp or xamp. these app have all in one so u don't need to install one by one messing up.

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

      Thanks :)

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

    okay I know this video is really old and I am probably going to sound stupid for this I figured out how to change the name and message color and move them around where I want to place them but when it comes to posted comments I can't seem to figure out where to move/change there color at all anyone know how?

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

      I know the video is old, the new version is: ruclips.net/video/0KwnPS5OhGI/видео.html
      What language did you use to make comments move around? PHP can't do it, so to change the color or position you will need JavaScript.

  • @kunnelantonyjacob851
    @kunnelantonyjacob851 9 лет назад

    sour cherry pls help me, i tried to paste in to my website, unfortunately it is showing error. It is showing the programming codes in the website under the comment box..

    • @lenakiki1179
      @lenakiki1179  9 лет назад

      Check your code here:
      #DISPLAY COMMENTS#
      $read = fopen("com.txt", "r+t");
      echo "All comments:";
      You could have missed the "; after All comments:

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

    hi there i know this is to late to ask but forgive me for asking because i really need this answer , i have data a stord on my php my admen and i can restor thim on i white page with all the data on it, my question how can i put thous data in to html table form instead of of white page, note that i am still learning php. so forgive me ^_^

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

    Thanks a lot!

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

    sour cherry i already type your codes but the problem is theres a paragraph here just like this and i just need it i will use it in my thesis it will help big a lot thanks :) :) :) and also i type it in notepad cuz i don't have notepad ++
    Name:
    Message:

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

    This is good! and I need this code to my website hehe Im just a advance or beginner programming

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

    How do i show the date and time and how do i show newest comments at the top and old comments down ?

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

    in your tutorial is it possible to put delete feature on the project?

  • @EpicDrake
    @EpicDrake 9 лет назад +1

    Getting error between $name
    $text
    ")fclose($write);#DISPLAY COMMENTS# and so much other words...

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

    Thank you😁

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

    It is local or global?

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

    good

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

    This brings me to something
    $name
    $text
    "); fclose($write); $read = fopen("com.text", "r+t"); echo "All Comments:
    "; while(!feof($read)){ echo fread($read, 1024); } fclose($read); } else{ $read = fopen("com.text", "r+t"); echo "All Comments:
    "; while(!feof($read)){ echo fread($read, 1024); } fclose($read); } ?>?
    What should I do?

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

      Are you sure you haven't missed a quote? The other reason might be that your file hasn't got .php extension or you don't have a local web server

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

    what is the "a+" and the "t+r" next to the com.txt????

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

    Hi,how do you make it display new comments above old comments? i tried ($read,1024) but its not working. please help

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

      It's explained in my updated video: ruclips.net/video/0KwnPS5OhGI/видео.html
      The code is in the comments

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

    can you please tell me how do i made comment post to another page...like if i enter comment and it goes to another html file...not the file in which is commentbox

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

      The action attribute in holds the URL of the file that processes the request. If it's " ", it means the same page, like in the video. You should put there the path to the file with the comments, for example 2.php:
      and in2.php the PHP code will be the same, but without if($_POST):

  • @Techie-d7g
    @Techie-d7g 5 лет назад

    osm

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

    Is php and html the same thing

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

    thanks for the video

  • @prince_gmng
    @prince_gmng 2 года назад +1

    8 year ago😮

  • @07shreyaspansare33
    @07shreyaspansare33 4 года назад

    Can We Publish This?LIKE ON WEB

  • @adamadam-io7nb
    @adamadam-io7nb 6 лет назад

    did we need to write php in html?

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

    Works pretty good and can be tweaked to fit your website. How do you get the com.txt load each time you visit the page?, it seems it only shows up after you make a comment.

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

    Thanks..

  • @will.s657
    @will.s657 6 лет назад

    or do I need to buy a Domain?

  • @impaulgriffiths
    @impaulgriffiths 9 лет назад

    how do you make it display new comments above old comments?

    • @lenakiki1179
      @lenakiki1179  9 лет назад

      +impaulgriffiths This part of code - fopen("com.txt", "r+t") - opens the file in the mode "r+t" (the second parameter), which makes PHP write the new comments in the beginning of the file. That's why when PHP reads the file - fread($read, 1024) - it reads the comments that are on the top of the file first.

    • @impaulgriffiths
      @impaulgriffiths 9 лет назад

      sour cherry thank you [: cant wait to play with this later [:

  • @md.rakibulislam8064
    @md.rakibulislam8064 6 лет назад

    tnx

  • @jackplack3140
    @jackplack3140 10 лет назад

    thanks

  • @12397bmw
    @12397bmw 7 лет назад

    How to I make a comment box only allow people to comment if they are logged into my website

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

      Before the part in the PHP file put code to check if there is log in cookie (I suppose you use cookies?):

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

    it's working but theres an error msg in the webpage everytime i delete all the content in com.txt

  • @will.s657
    @will.s657 6 лет назад

    does this work in notepad? I don't have np++

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

      You don't need it. Its just a tool to write

  • @cristrinidad6932
    @cristrinidad6932 9 лет назад

    I did what I have to do and downloaded xampp.....
    what do I do next?
    thanks if you answer my question...

    • @lenakiki1179
      @lenakiki1179  9 лет назад

      After you install xampp you have to go to XAMPP Control Panel and click the Start buttons next to Apache and MySQL. Then create the files which I showed in the video and save them in C:\xampp\htdocs\ in a folder (it doesn't matter how you name it). To see the files in the browser write in the adress bar localhost/your folder

    • @cristrinidad6932
      @cristrinidad6932 9 лет назад +2

      thanks

  • @adamadam-io7nb
    @adamadam-io7nb 6 лет назад

    what is the function of php

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

    Исходный код, пожалуйста ?? Еще я из норильска, здесь очень ужасно

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

    thx for the vid. i'm making a video sharing website and i would like to add comment possibility

  • @akn.ctn34
    @akn.ctn34 7 лет назад

    I did everything on video. But I don't know how I can add to server. Can you help me? I installed "wampserver"

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

      Your code files should be in the root folder (www) for PHP to run. The path is usually "X(or the name of your virtual disk)/home/somefolder/www".

    • @akn.ctn34
      @akn.ctn34 7 лет назад

      Thank you for your responded. I found it. I copied code files there. I installed wamp server and I have a website. I created it with wix. I can add html code that. So now. What Should I do?

  • @obsidianfox8340
    @obsidianfox8340 9 лет назад

    Друг, а подскажи, как еще сделать вывод времени сообщения?

    • @lenakiki1179
      @lenakiki1179  9 лет назад

      Obsidian Fox Есть такая функция как date(), можно указать день, месяц, год и т.п., но для часов и минут будет выглядеть вот так:
      date('G:i');
      И вставляется в код вот так:
      #WRITE DOWN COMMENTS#
      $write = fopen("com.text","a+");
      $date = date('G:i');
      fwrite($write, "$date $name$text");
      fclose($write);
      $date будет переменной, в которой записывается время сообщения в момент комментирования.
      Вот здесь есть таблица со значениями функции date для месяца, дня, года и т.п: php.net/manual/ru/function.date.php

  • @imranqaf
    @imranqaf 10 лет назад

    Good job

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

    is there a way to color the text?

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

    privet
    Can we not put text area instead of
    Spasibo

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

    Thanks for this great video!
    But I have one question. Is it also possible to place the comments in a label?

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

      If you mean styling the user name, you can use CSS for the tag:
      b{ css code }

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

      Thanks for your reply! In this video the comments become under the label. But it would be nicer if the comments appear in a label (box) to and not under the label. Do you have a solution ...

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

      You have to edit the $string you write down in the .txt file and put it in a div (box):
      #Delete everything, write down new and old comments
      $write = fopen("comments.txt", "w+");
      $string = "".$Name."".$Comment."
      ".$old_comments;
      fwrite($write, $string);
      fclose($write);
      fclose($old);

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

      Thank you! I'm going to try... Let you know.

  • @xujinblade6899
    @xujinblade6899 9 лет назад

    How do you create the database ?

    • @lenakiki1179
      @lenakiki1179  9 лет назад +1

      It doesn't work with MySQL database, the comments are written down in a .txt file

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

    sir this does not work at all and i am really quite sad, all videos i watch all lead me to failure at this and i dont understand why. please help me understand why this does not work. :(

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

      +conner mcadams This code will work only if you have a local web server like Apache, XAMPP or Denwer. What happens when you run the code?

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

      it doesnt print write and doesnt show up.

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

      +conner mcadams Something's wrong with the code. Could you post it?

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

      Name:
      Message:



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

      Your code looks fine, but try to validade it using HTML Validator and PHP CodeCheck (Google It)... And Also, You should try to reconfigure your local server and update it...

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

    It can be exploited by XSS cuz it show the comment in html form

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

    Fabulous! But, please: how to display posts into ascending order, where the latest post is at the top (and the oldest at the bottom end)?

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

      I've made a new version of this video (with new posts on the top): ruclips.net/video/0KwnPS5OhGI/видео.html

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

      Большое спасибо! Thank you very much!

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

    who actually remembers all of this lol

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

    Can you please send me the source code

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

    please how can i creat a systeme comment without php just with html and CSs

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

      You can't. HTML can't receive information from the user and CSS is only for styling. You need PHP to get the comments, write them down in a file and then display them.

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

      Lena Kiki I do not want to save the content. I do not want to connect the page to a database just write comment

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

      So you want people to write something, press a button and then everything is deleted?

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

      No I want to create a web page only with html: someone can write a comment others can see this comment. I would love to save the comments with the nickname. But I use pycharm as a development environment I can not use php. That's the problem

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

      You can't save or display the comments without PHP. And why are you using pycharm? Is you programme in Python?

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

    Hello sir please send you html code.

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

    Can you please tell us code in comment box

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

    I don't understand the language😶

  • @user-vr3uj9sm8q
    @user-vr3uj9sm8q 7 лет назад +3

    BG?

  • @sandrovva
    @sandrovva 10 лет назад

    all of you cant open because you must have notepad ++ or php or css

  • @jkanto2843
    @jkanto2843 9 лет назад

    Thank you +sour cherry, I don't know where to keep the com.txt file?

    • @lenakiki1179
      @lenakiki1179  9 лет назад

      In the same folder where you keep index.php

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

    why my coding doesnt work? argh so stress !

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

      +PkahD Luffy do you have a local web server

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

    please give me a link of your code s

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

      This is an updated version:
      ruclips.net/video/0KwnPS5OhGI/видео.html
      The code is in the comments

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

    how to add it into html file?

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

      If you watch the video you'll get it. But I strongly recommend learning at least the basics of PHP and HTML before trying to do something more complex.

  • @steffin001
    @steffin001 10 лет назад

    the reason why this program is not running:
    nah !! we need xampp for us to run this code :( php needs xampp .. duh !! i forgot ;( (facepalm)

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

    why the hell you named this vid in english and then you make everything in russian?!

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

      It's not Russian, it's Bulgarian actually xD

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

    Rep for this +1

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

    kiki do you love me? Are you riding? :D

  • @morningstar5380
    @morningstar5380 10 лет назад

    better to use facebook comment box...

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

    Hey man, if you want to do a video, please talk.

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

      First, I'm not a man;
      Second, I think if English is not one's native language, it's better to make videos with captions instead of talking with an accent

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

      Absolutely not true. Hearing an accent is way better than reading. For reading, one can go to html pages. So, please jump over the hurdle of fear, and start talking. The accent is your true self, it can even be sexy or cute. Take my advice and speak. Remember, this is a video of sight and sound. I think you even have a pretty face, if you show your face as you explain, you will get even better ratings and better views. Let me know of your next video with speaking, please and I will be happy to watch. Lastly, I do apologize for thinking such a lovely face is a man. Do accept my apology.

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

    hi

  • @user-sv8zc2iw4z
    @user-sv8zc2iw4z 3 года назад

    wtf

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

      ??

  • @alexman1164
    @alexman1164 10 лет назад

    Thanks a lot!

  • @rennamoha2311
    @rennamoha2311 9 лет назад

    HI