Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

255 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ PHP Social Messenger

PHP Social Messenger is a near real-time messaging web app that lets users chat with each other, manage their profile, and manage contacts (search, block/unblock, clear history). It ships with a clean AJAX-driven UI, a lightweight RESTful API with built-in interactive API docs, and a simple MySQL schema β€” making it a solid reference project for learning classic PHP + jQuery/AJAX architecture.

PHP MySQL License

πŸ“š Table of Contents

✨ Features

1️⃣ Real-Time Messaging ⚑

βœ… Live updates: The chat polls the server every second via AJAX, so new messages appear without a manual refresh. βœ… Message status: Shows the last sender and unread message count per contact. βœ… Message actions: Users can edit, delete, or copy their own messages.

Real-Time Messaging

πŸ”‘ Login Page

Login Page

πŸ›  Default Users for Demo

All seed accounts share the same password: IQBOLSHOH.

πŸ‘€ Username πŸ”‘ Password πŸ“ Description
iqbolshoh IQBOLSHOH Developer / owner account
client IQBOLSHOH Test user 1
user_3 IQBOLSHOH Test user 2
user_4 IQBOLSHOH Test user 3
user_5 IQBOLSHOH Test user 4
user_6 IQBOLSHOH Test user 5
user_7 IQBOLSHOH Test user 6

2️⃣ Profile Management πŸ‘€

βœ… Edit profile: Update your profile picture, name, and password. βœ… View profile: See details of the person you are chatting with.

Profile Management

3️⃣ Contact Search πŸ”

βœ… Find contacts easily using the dynamic search bar. βœ… Manage contacts & see unread messages on the homepage.

Contact Search

4️⃣ Block Users 🚫

βœ… Block people from sending you messages. βœ… Blocked notifications: Users get alerts if they try to message someone who blocked them. βœ… Easily accessible block menu in the chat interface.

Block Users

5️⃣ Chat Interface πŸ’¬

βœ… Full message history when opening a chat. βœ… Delete or copy your own messages. βœ… Live syncing for a smooth messaging experience.

Chat Interface

6️⃣ Menu Options πŸŽ›οΈ

βœ… View profile of the person you're chatting with. βœ… Clear chat history with a specific user. βœ… Block user to prevent them from messaging you.

Menu Options


πŸ“‚ Project Structure

php-social-messenger/
β”œβ”€β”€ api/                    # RESTful backend endpoints (JSON responses)
β”‚   β”œβ”€β”€ auth/               # login, signup, logout, session & availability checks
β”‚   β”œβ”€β”€ doc.php             # Interactive, browsable API documentation
β”‚   β”œβ”€β”€ send_message.php, fetch_messages.php, edit_message.php, delete_message.php
β”‚   β”œβ”€β”€ fetch_contacts.php, fetch_profile.php
β”‚   └── change_user_status.php, check_user_status.php, clear_messages.php
β”œβ”€β”€ login/                  # Login page
β”œβ”€β”€ signup/                 # Signup page
β”œβ”€β”€ logout/                 # Logout handler
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ css/                # Stylesheets (chat, login/signup, profile modal)
β”‚   β”œβ”€β”€ js/                 # jQuery + SweetAlert2
β”‚   └── images/             # Screenshots & user profile pictures
β”œβ”€β”€ chat.php                # Main chat interface (requires login)
β”œβ”€β”€ index.php                # Homepage / contact list
β”œβ”€β”€ config.php               # Database connection & query helper class
β”œβ”€β”€ database.sql             # Schema + demo seed data
└── README.md

πŸ“– API Documentation

Every endpoint is documented with purpose, method, required parameters, and example request/response β€” browse it live once the app is running:

http://localhost/php-social-messenger/api/doc.php
# Endpoint Method Purpose
1 api/auth/login.php POST Authenticate a user and start a session
2 api/auth/logout.php POST End the current session
3 api/auth/signup.php POST Register a new account
4 api/auth/check_availability.php POST Check if a username/email is already taken
5 api/auth/check_login.php SESSION Verify whether the current session is logged in
6 api/change_user_status.php POST Block / unblock a user
7 api/check_user_status.php POST Check if you are blocked by another user
8 api/clear_messages.php POST Delete the conversation with a user
9 api/delete_message.php POST Delete a single message
10 api/edit_message.php POST Edit a previously sent message
11 api/fetch_contacts.php GET List contacts, with optional ?search= filter
12 api/fetch_messages.php POST Fetch the full conversation with a contact
13 api/fetch_profile.php POST Fetch the logged-in user's profile
14 api/send_message.php POST Send a new message

πŸ“‹ Requirements

  • PHP 7.4+ (with the mysqli extension enabled)
  • MySQL / MariaDB
  • Apache or Nginx (or PHP's built-in server for local testing)

βš™οΈ Installation Guide πŸ› οΈ

Follow these steps to set up PHP Social Messenger on your local server:

1️⃣ Clone the Repository πŸ“₯

git clone https://github.com/Iqbolshoh/php-social-messenger.git

2️⃣ Navigate to the Project Directory πŸ“‚

cd php-social-messenger

3️⃣ Set Up the Database πŸ—„οΈ

database.sql already creates the database and seeds demo data, so just import it directly:

mysql -u yourusername -p < database.sql

This creates the social_messenger_db database, its tables, and 7 demo users.

4️⃣ Configure Database Connection ⚑

  • Open config.php and update your database credentials if they differ from the defaults:
    define("DB_SERVER", "localhost");
    define("DB_USERNAME", "root");
    define("DB_PASSWORD", "");
    define("DB_NAME", "social_messenger_db");

5️⃣ Run the Application πŸš€

  • Deploy on a PHP-compatible server (e.g., Apache, Nginx), or use PHP's built-in server for quick testing:
    php -S localhost:8000
  • Open your browser and go to: http://localhost/php-social-messenger (or http://localhost:8000 if using the built-in server)

πŸ–₯ Technologies Used

HTML CSS Bootstrap JavaScript jQuery Font Awesome PHP MySQL

πŸ“œ License

This project is open-source and available under the MIT License.

🀝 Contributing

🎯 Contributions are welcome! If you have suggestions or want to enhance the project, feel free to fork the repository and submit a pull request.

πŸ“¬ Connect with Me

πŸ’¬ I love meeting new people and discussing tech, business, and creative ideas. Let's connect! You can reach me on these platforms:

Website Gmail GitHub Telegram WhatsApp Instagram YouTube

About

πŸ’¬ PHP Social Messenger is a real-time ⚑ chat application built with PHP, MySQL πŸ›’οΈ, and AJAX πŸ”„. It supports: πŸ“¨ Instant messaging πŸ™‹β€β™‚οΈ Profile management πŸ” Contact search β›” User blocking 🧩 RESTful API for easy integration πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages