# 🚀 QUICK START GUIDE - CrimeSafe Map

## ⚡ 5-Minute Setup

### Step 1: Extract Files (✅ Done!)
```
Your files are in: /php-project/
```

### Step 2: Start Your Server

#### Option A: XAMPP (Recommended)
1. Copy `php-project` folder to `C:/xampp/htdocs/`
2. Start XAMPP Control Panel
3. Start **Apache** & **MySQL**
4. Go to: `http://localhost/phpmyadmin`

#### Option B: PHP Built-in Server
```bash
cd php-project
php -S localhost:8000
```

### Step 3: Create Database

Open phpMyAdmin and run:
```sql
CREATE DATABASE crimesafe_map;
USE crimesafe_map;
SOURCE database.sql;
```

Or import the file:
1. Click **Import** in phpMyAdmin
2. Choose `database.sql`
3. Click **Go**

### Step 4: Configure Database

Edit `/php-project/config/database.php`:
```php
define('DB_HOST', 'localhost');
define('DB_USER', 'root');         // Your username
define('DB_PASS', '');             // Your password
define('DB_NAME', 'crimesafe_map');
```

### Step 5: Test Installation

Visit: `http://localhost/php-project/setup.php`

If all green ✓:
- Click **"Launch CrimeSafe Map"**
- You're done! 🎉

---

## 🔐 Test Accounts

### Citizen
- **Email:** user@example.com
- **Password:** password

### Police Agency
- **Email:** police@dhaka.gov.bd
- **Password:** password

### RAB Agency
- **Email:** rab@dhaka.gov.bd
- **Password:** password

---

## 📱 Main Features to Test

### 1. **Live Map** (`?page=map`)
   - View crime markers on map
   - Filter by crime type
   - Click markers for details

### 2. **Report Crime** (`?page=report`)
   - Login first!
   - Select crime type
   - Pick location on map
   - Submit report

### 3. **Community** (`?page=community`)
   - Login as Agency to create posts
   - Like & comment as any user
   - Real-time engagement

### 4. **Analytics** (`?page=analytics`)
   - View crime statistics
   - See charts and graphs
   - Trending locations

### 5. **Agency Dashboard** (`?page=agency-dashboard`)
   - Login as Agency user
   - Verify pending reports
   - Manage posts
   - View statistics

---

## 🐛 Common Issues

### "Database connection failed"
```
✓ Check MySQL is running
✓ Verify credentials in config/database.php
✓ Database 'crimesafe_map' exists
```

### "Tables not found"
```
✓ Import database.sql in phpMyAdmin
✓ Check database name is correct
```

### "Map not loading"
```
✓ Internet connection needed (for Leaflet CDN)
✓ Check browser console for errors
```

### "404 Page Not Found"
```
✓ Verify .htaccess is present
✓ Check Apache mod_rewrite is enabled
```

---

## 📂 File Structure

```
php-project/
├── setup.php                 ← Start here!
├── index.php                 ← Main entry point
├── database.sql              ← Database structure
├── logout.php                ← Logout functionality
├── .htaccess                 ← Apache config
│
├── config/
│   └── database.php          ← Database connection
│
├── includes/
│   ├── header.php            ← Site header
│   └── footer.php            ← Site footer
│
├── pages/
│   ├── home.php              ← Landing page
│   ├── login.php             ← Login/Register
│   ├── map.php               ← Live crime map
│   ├── report.php            ← Report crime
│   ├── community.php         ← Community posts
│   ├── analytics.php         ← Statistics
│   └── agency-dashboard.php  ← Agency features
│
└── api/
    ├── add-comment.php       ← Add comment API
    ├── get-comments.php      ← Fetch comments API
    └── toggle-like.php       ← Like/unlike API
```

---

## 🎯 Testing Workflow

### Test as Citizen:
1. ✅ Register new citizen account
2. ✅ Login with citizen credentials
3. ✅ View live map
4. ✅ Report a crime
5. ✅ View community posts
6. ✅ Like and comment on posts
7. ✅ Check analytics

### Test as Agency:
1. ✅ Login with agency credentials
2. ✅ Access agency dashboard
3. ✅ Verify pending reports
4. ✅ Create community post
5. ✅ View engagement statistics
6. ✅ Comment on posts

---

## 🔧 Customization

### Change Color Scheme:
Edit the gradient colors in CSS:
```css
background: linear-gradient(135deg, #00d26a 0%, #00b859 100%);
```

### Add More Crime Types:
Edit in:
- `pages/report.php` (line ~50)
- `pages/map.php` (line ~90)

### Modify Email Template:
Look for notification messages in each page.

---

## 📞 Need Help?

1. ✅ Check `README.md` for detailed documentation
2. ✅ Run `setup.php` to verify installation
3. ✅ Check browser console (F12) for errors
4. ✅ Check PHP error logs

---

## ✨ What's Included?

✅ Complete user authentication (dual system)
✅ Interactive Leaflet.js maps
✅ Real-time crime reporting
✅ Community engagement (posts, likes, comments)
✅ Analytics with Chart.js
✅ Agency dashboard with verification
✅ Mobile responsive design
✅ Security features (prepared statements, password hashing)
✅ Clean URL routing
✅ AJAX for real-time updates

---

## 🚀 Ready to Go!

1. Follow Steps 1-5 above
2. Visit `setup.php` to verify
3. Login and explore!

---

**Made with ❤️ for Bangladesh 🇧🇩**

**Happy Coding! 🎉**
