Want To Add A Comments Section To My Website - Can PHP Do This?

Discussion in 'PHP' started by bad_bob00, Oct 26, 2009.

  1. #1
    Hi,

    I've got a website (just a static HTML site) but I think I've got a few MySQL databases available to use on my web hosting package, and can use PHP.

    I'm just wondering, is there a way of adding a comments section to the pages of my website? So at the bottom of my articles people can just post a comment?

    Would PHP be the best way to do this?


    Thanks for any help :)
     
    bad_bob00, Oct 26, 2009 IP
  2. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Yes. This is possible, but after programming you need to store all your articles in the database and because it's html files you need to use .htaccess to convert the script to HTML.

    Good Luck.
     
    mab, Oct 26, 2009 IP
  3. DollaradeConner

    DollaradeConner Active Member Affiliate Manager

    Messages:
    200
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Definitely, PHP would be perfect for something like this.

    The way I'd go about it is setting up a table for all of my articles, where each one has it's own unique id. Then, create a separate table for storing comments, and have the comment row store the article id it's meant for.

    The comment form would be at the bottom of each article, and you can store the id for that article in a hidden input on page. Then when someone submits a comment, your script will get all of their input along with the id of the article, and insert the new comment row.
     
    DollaradeConner, Oct 26, 2009 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yup, could even AJAX it up
     
    JAY6390, Oct 26, 2009 IP
  5. travelmoth

    travelmoth Active Member

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    I think that it's better to use open source CMS to manage your articles. Then it will be easy to add a comments section........and....other functions.
     
    travelmoth, Oct 26, 2009 IP
  6. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is true. Could import it all into a Drupal or Wordpress or such like. Would have commenting enabled too
     
    JAY6390, Oct 26, 2009 IP
  7. Gungz

    Gungz Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    PHP can absolutely do it.
    Learn PHP so that you can people can start commenting on your articles.
     
    Gungz, Oct 27, 2009 IP
  8. dhaval300

    dhaval300 Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yes php is good choice...... U could import it all into Wordpress or such like.
     
    dhaval300, Oct 28, 2009 IP
  9. bad_bob00

    bad_bob00 Active Member

    Messages:
    3,472
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #9
    Thanks for all the help. When I said can PHP do this, I was meaning is this the best/easiest way of doing it? Or are there other, simpler ways?


    Thanks again
     
    bad_bob00, Oct 28, 2009 IP
  10. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #10
    No. I'd say PHP is the way to go. If you have no programming experience, I'd recommend using a script, though.
     
    ThomasTwen, Oct 28, 2009 IP
  11. phatuis

    phatuis Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    PHP would be easy to do for this script.
     
    phatuis, Oct 29, 2009 IP
  12. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #12
    Sipifi, Oct 29, 2009 IP
  13. bad_bob00

    bad_bob00 Active Member

    Messages:
    3,472
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #13
    Sorry guys one more point I forgot to add - I'm hoping to make it as SEO friendly as possible, i.e. I want to add a comments section to every page not only because I want users to be able to instantly leave feedback/ask questions but also because I want this to be seen as new, unique content and to show that people read my site (and hopefully the search engines will like this aspect).

    Just thought I would say that incase some methods of adding a comment system are more SEO friendly then others?

    Thanks
     
    bad_bob00, Oct 29, 2009 IP
  14. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #14
    The easiest programming language to do this imo is PHP with MYSQL.

    Each entry in the table comments would link to an article id, which can be referenced in the articles table.

    Then if comment id == current article id, display it!

    Although if you are looking for a plug and play solution, you can obviously use something like WordPress.

    As for the SEO factor, if you can view the source of your page, and the comments are clearly there in the HTML than the Search Engine can see them.

    Factors that might affect this are some pagination scrips, meaning the SE doesn't see all of the comments, only the 1st page, or if it is using some funky JS to output the data for some reason.
     
    wd_2k6, Oct 29, 2009 IP
  15. organicCyborg

    organicCyborg Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I wish comments worked like that. I just get spam and idiots. :-P

    As far as the "easiest" way to implement this goes, You could make a script to include at the bottom of your pages. This script would store and retrieve comments in a database table by the URL of the page the script was included to. Which means you wouldn't have to manually enter every page you wanted comments on into a database. Is it a little janky? Yes. But it's easy and it works pretty well.

    Add a captcha if you want to avoid all the spam.
     
    organicCyborg, Oct 29, 2009 IP
  16. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Or an extra field with a simple maths sum or something! Change this to an image or different questions if you find somehow spam is getting through.
     
    wd_2k6, Oct 29, 2009 IP
  17. phatuis

    phatuis Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Using PHP to implement this, you could have say a table named articles and one named comments, in comments you would have aid (article id), and text, user etc. Then all you would do is "SELECT * FROM `comments` WHERE aid='".$aid."', and $aid = $_GET['article'] or whatever the GET used would be.
     
    phatuis, Oct 29, 2009 IP
  18. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #18
    God, I remember when I first started out and I wanted a comment script. I searched high and low for what I was looking for and couldn't find them. Thank god I learned PHP and MySQL haha.

    If you know PHP you could look for a script and edit it or ask someone for one.
     
    scottlpool2003, Oct 31, 2009 IP
  19. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #19
    astrazone, Oct 31, 2009 IP