A minimal, real-time-feeling chat app built with plain PHP, MySQL, and vanilla JS.
No frameworks. No build step. Just clean code and live conversations.
AnyoneHere is a lightweight one-to-one messaging app. Sign up, see who's online right now, and jump into a conversation — all wrapped in a clean, dark-and-white interface inspired by modern messaging apps.
It's built without any frameworks on purpose: just mysqli prepared statements, a sprinkle of fetch(), and old-fashioned short-polling to simulate real-time updates. A great reference project if you want to understand how chat apps work under the hood before reaching for sockets.
| 🔐 Secure Auth | Passwords hashed with password_hash(), verified with password_verify() |
| 🟢 Live Presence | Heartbeat pings every 5s mark users "online" for a 10-second window |
| 👥 Active Users List | Dashboard shows everyone currently online, refreshed automatically |
| 💬 1-on-1 Conversations | Clean chat bubbles with sender/receiver styling |
| 🔄 Auto-Refreshing Chat | Messages poll every second — no page reloads needed |
| 🧹 Self-Cleaning | Messages older than 24 hours are purged automatically |
| 📱 Responsive UI | Mobile-friendly layout with safe-area support for notched devices |
| 🛡️ SQL Injection Safe | Every query uses parameterized statements |
- Backend: PHP (
mysqli, prepared statements) - Database: MySQL
- Frontend: Vanilla HTML, CSS, JavaScript (no frameworks, no dependencies)
- Realtime simulation: Client-side polling (
fetch+setInterval)
anyonehere/
├── index.php # Login page
├── register.php # Account creation
├── dashboard.php # List of currently active users
├── conversation.php # 1-on-1 chat view
├── send-message.php # Handles new message submission
├── fetch-messages.php # Polled endpoint that renders message history
├── heartbeat.php # Updates last_seen timestamp for presence
├── user-status.php # Returns online/offline status for a user
├── style.css # Global styles (auth, dashboard, chat)
├── script.js # Polling, heartbeat, send/receive logic
├── config.example.php # Template for DB credentials
├── config.php # Your local DB credentials (gitignored)
└── database.sql # Database schema
- PHP 7.4+ with the
mysqliextension - MySQL / MariaDB
- Any local server stack (XAMPP, MAMP,
php -S, etc.)
1. Clone the repository
git clone https://github.com/your-username/anyonehere.git
cd anyonehere2. Create the database
mysql -u root -p < database.sqlThis creates the chat database along with the users and messages tables.
3. Configure your environment
Copy the example config and fill in your own credentials:
cp config.example.php config.php$server = "localhost";
$username = "YOUR_DB_USERNAME";
$password = "YOUR_DB_PASSWORD";
$database = "YOUR_DB_NAME";
⚠️ Never commitconfig.phpwith real credentials. It's meant to stay local — keep it out of version control.
4. Run it
php -S localhost:8000Then visit http://localhost:8000 in your browser 🎉
Click to expand
users
| Column | Type | Notes |
|---|---|---|
id |
INT |
Primary key, auto-increment |
username |
VARCHAR(50) |
Unique |
password |
VARCHAR(255) |
Hashed with password_hash() |
last_seen |
DATETIME |
Used to determine online status |
messages
| Column | Type | Notes |
|---|---|---|
id |
INT |
Primary key, auto-increment |
sender_id |
INT |
FK → users.id |
receiver_id |
INT |
FK → users.id |
message |
TEXT |
Message content |
created_at |
TIMESTAMP |
Auto-purged after 24h |
- Every open session pings
heartbeat.phpevery 5 seconds, updatinglast_seen. - A user is considered online if their
last_seenis within the last 10 seconds. - The active chat polls
fetch-messages.phpevery 1 second to pull new messages, comparing the response against the last render to avoid unnecessary DOM updates. user-status.phppolls every 3 seconds to reflect the other person going online/offline in real time.
Give it a spin here → anyonehere.freehosting.dev
Create an account, open a second browser (or incognito tab), sign in as someone else, and chat with yourself in real time. 👻
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
This project is open source and available under the MIT License.
