# To-Do List App for Hostinger (PHP + MySQL + Multi-user)

Modern To-Do list with:
- Multi-user login / register
- Due date + time
- Recurring tasks (Daily / Weekly / Monthly / Yearly)
- Each user has their own private task list

## Files

| File           | Purpose                     |
|----------------|-----------------------------|
| `index.html`   | Frontend (UI + auth)        |
| `api.php`      | Backend API + authentication|
| `config.php`   | Database credentials        |
| `database.sql` | Creates `users` + `todos` tables |

## Setup on Hostinger

### 1. Create MySQL Database
1. Hostinger hPanel → **Databases → MySQL Databases**
2. Create database + user
3. Grant **All Privileges**

### 2. Import tables
1. Open **phpMyAdmin**
2. Select your database
3. **Import** → choose `database.sql` → Go

### 3. Edit credentials
Open `config.php` and put your real values:

```php
define('DB_HOST', 'localhost');
define('DB_NAME', 'u123456789_todo');
define('DB_USER', 'u123456789_todo');
define('DB_PASS', 'your_strong_password');
```

### 4. Upload files
Upload these files to `public_html` (or a subfolder):

```
public_html/
├── index.html
├── api.php
├── config.php
└── database.sql   (optional after import)
```

### 5. Done
Open your domain.  
You will see the **Login / Register** screen.

---

## Features

- Register with username + email + password
- Login with username **or** email
- Secure password hashing (`password_hash`)
- PHP sessions
- Each user only sees their own tasks
- Recurring tasks auto-create the next occurrence
- Filters: All / Active / Completed / Overdue

## Security notes

- Passwords are hashed (never stored in plain text)
- All queries use prepared statements
- Todos are protected by `user_id` ownership check
- Sessions are used for authentication

If you later want HTTPS-only cookies, CSRF protection, or email verification, we can add them.
