# PowerZone Database Setup Guide

## Quick Start

### Step 1: Initialize Database
1. Open your browser and go to: `http://localhost/fitness/setup-database.php`
2. This will automatically create all necessary tables in your database

### Step 2: Admin Login
- **URL:** `http://localhost/fitness/admin-login.php`
- **Username:** `admin`
- **Password:** `admin123`

### Step 3: Member Dashboard
- Members can access their dashboard at: `http://localhost/fitness/member-dashboard.php`

---

## Database Tables Created

The setup script creates the following tables:

### 1. **users**
- Full name, email, password, phone
- Fitness goal, timestamps

### 2. **appointments**
- User appointments with dates and times
- Status tracking (pending, confirmed, completed, cancelled)

### 3. **blog_posts**
- Blog articles with title, content, author
- Status management (published, draft, archived)

### 4. **services**
- Fitness services with description and pricing
- Service status and duration

### 5. **events**
- Fitness events with dates and locations
- Event capacity and images

### 6. **products**
- Shop products with pricing and stock
- Product images and categories

### 7. **orders**
- Customer orders with totals
- Order status tracking and shipping info

### 8. **order_items**
- Individual items in orders
- Quantity and price per item

### 9. **team_members**
- Team member profiles
- Position, contact info, social links

### 10. **contact_messages**
- Contact form submissions
- Status management

### 11. **admin**
- Admin user accounts
- Login credentials

---

## Features Now Available

✅ **Admin Dashboard** - Manage all website content
- View member statistics
- Manage appointments
- Track orders and revenue
- Manage blog posts, events, services
- Team management

✅ **Member Dashboard** - For registered users
- View personal appointments
- Track orders
- Browse services and events
- Update profile

✅ **Database** - Fully normalized with:
- Foreign key relationships
- Automatic timestamps
- Proper data types and constraints

---

## Troubleshooting

### Table Not Found Error
If you still get "table doesn't exist" error:
1. Run `setup-database.php` again
2. Check that XAMPP MySQL is running
3. Verify database name is `powerzone_db`

### Admin Login Issues
If admin login fails:
1. Go to `setup-database.php` again
2. It will recreate the admin account with default credentials

### Database Connection Error
Make sure:
- XAMPP MySQL is running
- Database `powerzone_db` exists
- Connection settings in `includes/db.php` are correct:
  ```php
  $conn = mysqli_connect("localhost", "root", "", "powerzone_db");
  ```

---

## Next Steps

1. ✅ Run setup-database.php
2. ✅ Login to admin dashboard
3. ✅ Add sample content (services, events, blog posts)
4. ✅ Create member accounts
5. ✅ Test member dashboard

---

## Support

For issues or questions, please check:
- Admin dashboard for content management
- Member dashboard for user features
- Database structure matches your needs
