This is a simple PHP-based word censoring program that filters out offensive or banned words from user-inputted text. The banned words are stored in a database, making it easy to update and manage the list dynamically.
- Stores banned words in a MySQL database
- Dynamically censors words from user input
- Case-insensitive word filtering
- User-friendly interface with Bootstrap styling
- Displays original and censored text
- Prepared for future admin interface to manage banned words
- PHP
- MySQL
- Bootstrap 5
- JavaScript
git clone https://github.com/your-username/php-word-censor.git
cd php-word-censor- Create a new database named
censor_db. - Run the following SQL command to create the
banned_wordstable: GPT
CREATE TABLE banned_words (
id INT AUTO_INCREMENT PRIMARY KEY,
word VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- Insert sample banned words:
use the insert.php file to insert 200 censored words generated by ChatGPTUpdate the config.php or the database connection section in index.php:
$servername = "localhost";
$username = "root"; // Replace with your database username
$password = ""; // Replace with your database password
$dbname = "censor_db";Host the project on a local server using XAMPP, WAMP, or a similar PHP server.
- Move the project folder to
htdocs(if using XAMPP). - Start Apache and MySQL.
- Open a browser and go to:
http://localhost/php-word-censor/
- Enter a text containing offensive words.
- Click "Censor Text."
- The system will replace banned words with asterisks (e.g., "*****").
- Admin interface to manage banned words
- Enhanced word matching with regex support
- Option for user-defined banned words
This project is open-source. Feel free to modify and improve it.
Pull requests are welcome! If you have suggestions, open an issue first to discuss changes.
⭐ Star the repo if you found this useful! 🚀