/    Sign up×
Community /Pin to ProfileBookmark

How to make a barebones PHP/JS comments system?

Okay, so I’m trying to make a barebones comment system inside a PHP page where all the server and client sided code will be inside that page.
My idea is that every time a user loads up the page, a JS script will update a list element inside a page using an array variable set by a PHP echo.
So for example
([NoPaste snippet](https://nopaste.ml/?l=php#XQAAAQAVBQAAAAAAAAAeD8qHAhP+0bIjgkb3WSRfV85AQ+uXMxtlnm37DTswBKe2568HwOH3j7Bt5nM2hooFG4xCOZ3aKV7Q8hvT0l7mx8APLPhgZG/htyjQNliU48Q84VRx2NFbRM+eSfZp+fDkVEaU5JIKiTDrcFWs1lKW/eEqskWIq7Bptu9kq3nY5LwLcTyJlsL6fK2o5dsxlRf9aByPFW1xLSWerWcNkCyltzCTm1SMpZroa2ecasAbffVOCh/+7HjztAR8H73r4j2dyaDtP05MxdPcXRq+WOqzYXIYurFohwEJhuZGVy8XukbRtasET2T9cDXwUEv998U001WOzAoaggvLLDVfu24k0vdlc7VhoA0rGGOcZrDiK0pOKIZ3svC4q7BQTJknKRQgNXeh8CLWO3j1S16GAtI6YcHnlxFs7XVTiJZL+bWTWp2GHl3NfxYVXAZAB3hpAHHjGYWWBIyProxkqWmVJTDIZ5oDCEVjhewv8gW4wqo07yFAsh+6TP9KhTt9b+oTaFSI+r5aFq1/Q0CgSNhVvix8gJli4NHloZJQBxOvPk0fP3f6t35AbXhb/hNZxOXw/YTzqUWAI9lF2aBYrqSrDYK5yI3m3u+enXtsGbu9WxjamsxX3IQjaEah9SyDdmmVS4AVf7nG2aLVmNrUjkp096N4BMsNOVtc7dG4P4o21EaEdqfwcAJS02R8aO0IzaT+sqNNauWLl+A34rVzB99XUMQLFhb0jmn/ja8tUCr6jCwkCjOCk/YDHT0bSpVjive96PwLmf6iXmN/NG45bY8YjBCgAkxK/HF1TEvFAd/1fKfnflnocNfghz/nG4+fb0f+rgRj))
Basically this file will hold the serversided comment loading/posting logic and the page with JS itself. I don’t want to make a separate comments.php file as that will increase hit amounts. Every IP has a 5 second cooldown to prevent DDOS attacks, and the comments themselves will be an array inside a JSON file.

How do you turn this code concept into a real thing?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@FrancescoDickensFeb 05.2023 — Creating a barebones PHP/JS comments system requires a few simple steps:

  • 1. Create a page for displaying the comments. This page should have an HTML form for submitting comments, and a list of comments already submitted.


  • 2. Create a PHP script for handling comment submissions. This script should check for malicious input and store the comment in a database.


  • 3. Create a JavaScript file for retrieving comments from the database and displaying them on the page.


  • 4. Connect the HTML form to the PHP script using AJAX so that comments can be submitted without refreshing the page.


  • 5. Add some basic styling to the comments list so that it looks nice and is easy to read.


  • By following these steps, you can easily create a basic ::comments system using PHP and JavaScript.:::
    ×

    Success!

    Help @agagaga spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...