PHP/MySQL: How to create a comment section in your website

111,870

It's a hard question to answer without more information. There are a number of things you should consider when looking at implementing commenting on an existing website.

How will you address the issue of spam? It doesn't matter how remote your website is, spammers WILL find it and they'll filled it up in no time. You may want to look into something like reCAPTCHA (http://recaptcha.net/).

The structure of the website may also influence how you implement your comments. Are the comments for the overall site, a particular product or page, or even another comment? You'll need to know the relationship between the content and the comment so you can properly define the relationship in the database. To put it another way, you know you want an email address, the comment, and whether it is approved or not, but now we need a way to identify what, if anything, the comment is linked to.

If your site is already established and built on a PHP framework (CakePHP for instance) you'll need to address how to integrate your code properly with what is already in place.

Lastly, there are a number of resources and tutorials on the web for PHP. If you do a quick google search for something along the lines of "PHP blog tutorial" I'm sure you'll find hundreds and the majority will show you step by step how to implement comments.

Share:
111,870
Admin
Author by

Admin

Updated on January 03, 2020

Comments

  • Admin
    Admin over 4 years

    Instead of asking 'how to use PHP/MySQL to let users affect webpages' I'll ask this, because I learn better from projects and examples.

    So how would I incorporate a VERY basic comment feature using PHP and MySQL?

  • Jon Winstanley
    Jon Winstanley almost 15 years
    Also, read a guide to avoiding SQL injection
  • rtacconi
    rtacconi almost 15 years
    Dear Jon, this comment is just inappropriate.
  • Dancrumb
    Dancrumb about 14 years
    I think you may be reading more into Jon's comment than is there. I believe this is simply an addendum to your answer to highlight the need to understand SQL injection attacks. I do not believe he is trying to impugn you or undermine your answer.
  • Your Common Sense
    Your Common Sense about 14 years
    I bet the op already got his comments ;)
  • pratik
    pratik over 11 years
    book is good but not a solution ...........!!!
  • ands
    ands about 7 years
    You have nicely explained what problems will OP face when creating a comment section in website, but you didn't answer the question and more importantly I think you haven't understood the question either. OP is asking how to make a basic comment feature using PHP and MySQL not because he wants to make social site but because he wants to know "how to use PHP/MySQL to let users affect webpages" so he doesn't care about spam, reCAPTCHA , relationship between the content and the comment and other problems.