This project contains a simple comment system allowing users to read, add, edit, and delete comments (CRUD operations). The system is built using a combination of PHP for server-side logic and JavaScript for client-side interactivity. Comments are stored in a MySQL database.
To run this project locally, follow these steps:
-
Server Environment:
- Set up a local server environment such as XAMPP, WAMP, or your preferred alternative.
-
Database Setup:
-
Create a new database called 'comment_system' using PHPMyAdmin or any MySQL database management tool.
-
Run the following SQL commands to set up the 'comments' table:
CREATE DATABASE IF NOT EXISTS comment_system; USE comment_system; CREATE TABLE IF NOT EXISTS comments ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, comment TEXT NOT NULL, submit_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-
Clone the Repository:
- Clone this repository to your local machine.
-
Run the Project:
- Open the project in your chosen server environment.
- Access the project through your web browser.
-
View Comments:
- Display all comments on the main page (index.php).
- Each comment shows the author, creation date, and message.
-
Add New Comment:
- Users can write and submit new comments through the "Write a comment" form.
-
Edit Comment:
- Edit existing comments by clicking the "Edit" button.
- Redirects to the commentForm.php page for editing.
-
Delete Comment:
- Delete comments with a confirmation prompt.
- Dynamically updates the DOM to remove the deleted comment.
-
Comment Form:
- commentForm.php handles both adding new comments and editing existing ones.
- Uses the Fetch API to communicate with PHP for server-side operations.
-
Response Handling:
- Responses from server-side actions are displayed as message boxes with appropriate styling.
- Alerts indicate success, blank input errors, or fatal errors.
-
Redirect to Home:
- App redirects users to the main page after a successful operation of adding/editing comment.
This project does not include a login system or role system.

