# XAMPP setup for voter app

"Service unavailable" when opening http://localhost/voter/vote means **the database connection failed**.

## 1. Start MySQL in XAMPP

- Open XAMPP Control Panel.
- Start **Apache** and **MySQL**.

## 2. Create database and user

In **phpMyAdmin** (http://localhost/phpmyadmin) or MySQL command line, run:

```sql
CREATE DATABASE IF NOT EXISTS voter CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'voter_user'@'127.0.0.1' IDENTIFIED BY 'StrongPass#2026';
GRANT ALL PRIVILEGES ON voter.* TO 'voter_user'@'127.0.0.1';
FLUSH PRIVILEGES;
```

Then import the schema and (optionally) seed:

- In phpMyAdmin: select database `voter` → Import → choose `db/schema.sql`, then `db/seed.sql` if you want sample data.

Or from the project folder in a terminal:

```bash
mysql -u voter_user -p voter < db/schema.sql
mysql -u voter_user -p voter < db/seed.sql
```

## 3. Or use root for local dev

If you prefer to use MySQL **root** with no password, edit `config/config.php`:

```php
const DB_USER = 'root';
const DB_PASS = '';
```

Create the database and import schema:

```sql
CREATE DATABASE IF NOT EXISTS voter CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

Then import `db/schema.sql` and optionally `db/seed.sql` into `voter`.

## 4. Reload the app

Open http://localhost/voter/vote again. If MySQL is running and the database/user match `config/config.php`, the vote page should load.
