A comprehensive PHP-based web application promoting awareness about UN Sustainable Development Goal 15: Life on Land. This platform educates users about protecting terrestrial ecosystems, sustainably managing forests, combating desertification, halting biodiversity loss, and reversing land degradation.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Database Schema
- User Roles
- Pages Overview
- API Endpoints
- Security Features
- Contributing
- User Registration with email validation
- Secure Login with password hashing (bcrypt)
- Remember Me functionality with cookies
- Password Reset via email verification
- Role-based Access Control (Admin/User)
- Create Posts with rich content and image uploads
- Tag System for categorizing posts (Environment, Conservation, Policy, etc.)
- Like System for posts and comments
- Comment System with nested discussions
- Search & Filter posts by title, content, or tags
- Sort Options (Newest, Oldest, A-Z, Z-A)
- Content Moderation - Ban/Unban posts and comments
- View Banned Content - Review moderated content
- User Management - Admin role identification
- About Page - SDG 15 mission, causes, statistics, and impacts
- Initiatives - 6 detailed initiative pages covering:
- Environmental Education
- Reforestation Programs
- Wildlife Protection Laws
- NGO Partnerships
- FSC Certification
- Public Awareness Campaigns
- Resources - Reports, case studies, and analysis
- Events - Upcoming environmental events and campaigns
- Donation System - Support conservation efforts
- Volunteer Opportunities - Tree planting, awareness campaigns
- Contact Form - Direct communication channel
| Category | Technology |
|---|---|
| Backend | PHP 8.x |
| Database | MySQL 5.7+ / MariaDB |
| Frontend | HTML5, CSS3, JavaScript |
| CSS Framework | Custom CSS with modern styling |
| JavaScript Libraries | jQuery 3.6, Select2 |
| Icons | Font Awesome 6.5 |
| Server | Apache (XAMPP) |
sdg15-awareness-website/
βββ Homepage.php # Landing page with SDG 15 overview
βββ LoginPage.php # User authentication
βββ SignUp.php # New user registration
βββ forgetPassword.php # Password recovery
βββ Resetpassword.php # Password reset handler
βββ logout.php # Session termination
β
βββ index.php # Community forum main page
βββ view_post.php # Individual post view with comments
βββ add_post.php # Create new post form
βββ edit_post.php # Edit existing post
βββ delete_post.php # Delete post handler
βββ insert_post.php # Post insertion handler
βββ update_post.php # Post update handler
β
βββ add_comment.php # Add comment handler
βββ delete_comment.php # Delete comment handler
βββ like.php # Post like toggle
βββ like_index.php # AJAX like handler for index
βββ like_comment.php # Comment like toggle
β
βββ ban.php # Ban/unban post (admin)
βββ ban_comment.php # Ban/unban comment (admin)
βββ banned_posts.php # View banned posts (admin)
β
βββ myprofile.php # User profile page
βββ my_posts.php # User's own posts
βββ liked_posts.php # User's liked posts
β
βββ about.php # About SDG 15
βββ initiatives.php # Initiatives overview
βββ initiative1.php - 6.php # Individual initiative pages
βββ resources.php # Educational resources
βββ events.php # Environmental events
βββ getinvolved.php # Donation & volunteering
βββ contactus.php # Contact form
β
βββ db_connect.php # Database connection & setup
βββ create_db.php # Database creation script
βββ create_table.php # Table creation script
βββ handle_contact.php # Contact form handler
βββ handle_donation.php # Donation form handler
βββ message.php # Flash message display
β
βββ article_search.js # Search functionality
β
βββ css/
β βββ index.css # Community page styles
β βββ view_post.css # Post view styles
β βββ input_post.css # Post form styles
β βββ profile_posts.css # Profile page styles
β
βββ images/ # Static images
βββ videos/ # Background videos
βββ uploads/ # User-uploaded images
β
βββ database.txt # SQL schema reference
βββ db.txt # Database documentation
Before installation, ensure you have:
- PHP 8.0+ with mysqli extension
- MySQL 5.7+ or MariaDB 10.x
- Apache web server with mod_rewrite
- XAMPP stack (recommended for local development)
# Clone the repository
git clone https://github.com/mewHacks/sdg15-awareness-website.git
# Or download and extract to your web server directory
# XAMPP: C:/xampp/htdocs/sdg15-awareness-website# Start Apache and MySQL via XAMPP control panel
# Or via command line:
sudo service apache2 start
sudo service mysql startThe database and tables are automatically created when you first visit the site!
The db_connect.php file handles:
- Creating the
user_systemdatabase - Creating all required tables
- Inserting a default admin user
Default Admin Credentials:
Email: admin@admin.com
Password: admin123
http://localhost/sdg15-awareness-website/Homepage.php
-- Users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL, -- bcrypt hashed
role ENUM('admin', 'user') DEFAULT 'user'
);
-- Posts table
CREATE TABLE posts (
post_id INT AUTO_INCREMENT PRIMARY KEY,
id INT NOT NULL, -- FK to users.id
title VARCHAR(100) NOT NULL,
content TEXT,
tags VARCHAR(255), -- comma-separated
images TEXT, -- comma-separated paths
likes INT DEFAULT 0,
banned TINYINT(1) DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Comments table
CREATE TABLE comments (
comment_id INT AUTO_INCREMENT PRIMARY KEY,
post_id INT NOT NULL, -- FK to posts.post_id
id INT NOT NULL, -- FK to users.id
comment TEXT NOT NULL,
comment_like INT DEFAULT 0,
banned TINYINT(1) DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Likes table (post likes tracking)
CREATE TABLE likes (
like_id INT AUTO_INCREMENT PRIMARY KEY,
id INT NOT NULL, -- FK to users.id
post_id INT NOT NULL, -- FK to posts.post_id
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_like (id, post_id)
);
-- CommentLikes table
CREATE TABLE CommentLikes (
Commentlikes_id INT AUTO_INCREMENT PRIMARY KEY,
id INT NOT NULL, -- FK to users.id
comment_id INT NOT NULL, -- FK to comments.comment_id
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_comment_like (id, comment_id)
);
-- Donations table
CREATE TABLE donations (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
amount DECIMAL(10, 2) NOT NULL,
donated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Contact messages table
CREATE TABLE contact_messages (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
message TEXT NOT NULL,
sent_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);βββββββββββββββ βββββββββββββββ βββββββββββββββ
β users β β posts β β comments β
βββββββββββββββ€ βββββββββββββββ€ βββββββββββββββ€
β id (PK) βββββββββ id (FK) β ββββΊβ comment_id β
β username β β post_id (PK)βββββ€ β post_id(FK) β
β email β β title β β β id (FK) β
β password β β content β β β comment β
β role β β tags β β β banned β
βββββββββββββββ β banned β β βββββββββββββββ
β βββββββββββββββ β
β β β
β βββββββ΄ββββββ β
β βΌ βΌ β
β βββββββββββ ββββββββββββββββ
ββββββββββΊβ likes β β CommentLikes β
βββββββββββ ββββββββββββββββ
- View all public content
- Create, edit, delete own posts
- Like posts and comments
- Add comments to any post
- Access profile and settings
- All regular user permissions
- View banned content
- Ban/Unban posts and comments
- Posts highlighted with special styling
- Access to moderation tools
| Page | URL | Description | Auth Required |
|---|---|---|---|
| Homepage | /Homepage.php |
Landing page with SDG 15 intro | No |
| Login | /LoginPage.php |
User authentication | No |
| Sign Up | /SignUp.php |
New user registration | No |
| Community | /index.php |
Forum with all posts | Yes |
| View Post | /view_post.php?post_id=X |
Single post with comments | Yes |
| Add Post | /add_post.php |
Create new post | Yes |
| Profile | /myprofile.php |
User profile & settings | Yes |
| About | /about.php |
SDG 15 information | Yes |
| Initiatives | /initiatives.php |
Conservation initiatives | Yes |
| Resources | /resources.php |
Educational materials | Yes |
| Events | /events.php |
Environmental events | Yes |
| Get Involved | /getinvolved.php |
Donation & volunteering | Yes |
| Contact | /contactus.php |
Contact form | Yes |
| Endpoint | Method | Purpose | Parameters |
|---|---|---|---|
like_index.php |
POST | Toggle post like | post_id |
like_comment.php |
POST | Toggle comment like | comment_id |
add_comment.php |
POST | Add new comment | post_id, comment |
ban.php |
GET | Ban/Unban post | post_id, action |
ban_comment.php |
GET | Ban/Unban comment | comment_id, action |
{
"success": true,
"like_count": 15,
"message": "Post liked successfully"
}-
SQL Injection Prevention
- Prepared statements with parameter binding
- No direct variable interpolation in queries
-
Password Security
- Bcrypt hashing via
password_hash() - Secure verification via
password_verify()
- Bcrypt hashing via
-
XSS Prevention
htmlspecialchars()on all user output- Input sanitization
-
Session Security
- Server-side session management
- Session-based authentication
-
Access Control
- Role-based permissions
- Authentication checks on protected pages
| Category | Tags |
|---|---|
| Environment & Conservation | Reforestation, Biodiversity, Forest Conservation, Wildlife Protection |
| Community & Participation | NGO Initiatives, Volunteering, Community Stories |
| Education & Insights | Education, Global Reports, Case Studies, Events |
| Policy & Sustainability | Sustainable Practices, Policy & Law |
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
For questions or issues, use the Contact Us page or open a GitHub issue.
This project is created for educational purposes to promote awareness of UN SDG 15: Life on Land.
π² Protecting Life on Land for a Sustainable Future π²
