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