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.
- Features
- Demo Accounts
- Project Structure
- API Documentation
- Requirements
- Installation Guide
- Technologies Used
- License
- Contributing
- Connect with Me
✅ 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.
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 |
✅ Edit profile: Update your profile picture, name, and password. ✅ View profile: See details of the person you are chatting with.
✅ Find contacts easily using the dynamic search bar. ✅ Manage contacts & see unread messages on the homepage.
✅ 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.
✅ Full message history when opening a chat. ✅ Delete or copy your own messages. ✅ Live syncing for a smooth messaging experience.
✅ View profile of the person you're chatting with. ✅ Clear chat history with a specific user. ✅ Block user to prevent them from messaging you.
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
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 |
- PHP 7.4+ (with the
mysqliextension enabled) - MySQL / MariaDB
- Apache or Nginx (or PHP's built-in server for local testing)
Follow these steps to set up PHP Social Messenger on your local server:
git clone https://github.com/Iqbolshoh/php-social-messenger.gitcd php-social-messengerdatabase.sql already creates the database and seeds demo data, so just import it directly:
mysql -u yourusername -p < database.sqlThis creates the
social_messenger_dbdatabase, its tables, and 7 demo users.
- Open
config.phpand 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");
- 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(orhttp://localhost:8000if using the built-in server)
This project is open-source and available under the MIT License.
🎯 Contributions are welcome! If you have suggestions or want to enhance the project, feel free to fork the repository and submit a pull request.
💬 I love meeting new people and discussing tech, business, and creative ideas. Let's connect! You can reach me on these platforms:






