# Spring Supports Mfg. Co. — CMS Setup Guide
## XAMPP Installation & Configuration

---

## 🗂 Project Structure

```
spring_cms/
├── index.php                ← Homepage (dynamic)
├── about.php                ← About page
├── products.php             ← Products listing
├── product-detail.php       ← Single product page (?slug=...)
├── engineering.php          ← Engineering process page
├── contact.php              ← Contact form page
├── contact-handler.php      ← Form submission handler
├── .htaccess                ← Apache config & security
│
├── config/
│   └── db.php               ← Database & path config ⚠ EDIT THIS
│
├── includes/
│   ├── functions.php        ← Helper functions
│   ├── header.php           ← Topbar + navigation
│   └── footer.php           ← Footer
│
├── assets/
│   ├── css/style.css        ← Main stylesheet
│   └── js/main.js           ← Slider, cursor, animations
│
├── uploads/                 ← All uploaded files (auto-created)
│   ├── products/
│   ├── slider/
│   ├── icons/
│   └── general/
│
├── admin/                   ← CMS Admin Panel
│   ├── index.php            ← Dashboard
│   ├── login.php            ← Admin login
│   ├── logout.php
│   ├── sliders.php          ← Manage hero slider
│   ├── products.php         ← Manage products
│   ├── categories.php       ← Manage categories
│   ├── about.php            ← About + stats + certs
│   ├── stats.php            ← Stats (numbers)
│   ├── certifications.php   ← Certifications
│   ├── features.php         ← Why Choose Us
│   ├── engineering.php      ← Engineering steps
│   ├── messages.php         ← Contact enquiries
│   ├── settings.php         ← Site-wide settings
│   ├── media.php            ← Media library
│   ├── password.php         ← Change password
│   ├── auth.php             ← Session guard
│   ├── css/admin.css        ← Admin stylesheet
│   └── includes/
│       ├── layout.php       ← Sidebar + topbar
│       └── layout_end.php   ← Closing tags
│
└── database.sql             ← Full DB schema + seed data
```

---

## ⚡ Quick Start (XAMPP)

### Step 1 — Install XAMPP
Download from https://www.apachefriends.org and install.

### Step 2 — Copy Project Files
Copy the `spring_cms` folder to:
```
C:\xampp\htdocs\spring_cms\       (Windows)
/Applications/XAMPP/htdocs/spring_cms/   (Mac)
```

### Step 3 — Start XAMPP
Open XAMPP Control Panel → Start **Apache** and **MySQL**.

### Step 4 — Create Database
1. Open browser → http://localhost/phpmyadmin
2. Click **New** → Database name: `spring_cms` → Create
3. Select `spring_cms` database
4. Click **Import** tab → Choose file → select `database.sql` → Go

### Step 5 — Configure Database Connection
Open `config/db.php` and update if needed:
```php
define('DB_HOST', 'localhost');
define('DB_NAME', 'spring_cms');
define('DB_USER', 'root');
define('DB_PASS', '');           // Add your MySQL password here if set
define('BASE_URL', 'http://localhost/spring_cms');
```

### Step 6 — Enable mod_rewrite (optional, for .htaccess)
In XAMPP: Apache → Config → httpd.conf
Uncomment: `LoadModule rewrite_module modules/mod_rewrite.so`
And find `AllowOverride None` → change to `AllowOverride All`

### Step 7 — Test the Website
- **Website:** http://localhost/spring_cms/
- **Admin Panel:** http://localhost/spring_cms/admin/

---

## 🔐 Admin Login Credentials

| Field    | Value       |
|----------|-------------|
| Username | `admin`     |
| Password | `Admin@123` |

> **IMPORTANT:** Change the password immediately after first login!
> Admin → Change Password (sidebar)

---

## 📋 Admin Panel Modules

| Module              | Path                     | What You Can Do                          |
|---------------------|--------------------------|------------------------------------------|
| Dashboard           | /admin/                  | Overview, recent messages                |
| Hero Slider         | /admin/sliders.php       | Add/edit/delete slides, text, links      |
| Products            | /admin/products.php      | Full product CRUD with image upload      |
| Categories          | /admin/categories.php    | Organise products into categories        |
| About Content       | /admin/about.php         | Company description, stats, certifications |
| Stats               | /admin/stats.php         | Numbers displayed in About section       |
| Certifications      | /admin/certifications.php| ISO and quality badges                   |
| Why Choose Us       | /admin/features.php      | 6-grid capability cards                  |
| Engineering         | /admin/engineering.php   | Process steps + feature list             |
| Messages            | /admin/messages.php      | View/reply to contact form enquiries     |
| Site Settings       | /admin/settings.php      | Logo, email, phone, footer, SEO          |
| Media Library       | /admin/media.php         | Upload and manage all images             |
| Change Password     | /admin/password.php      | Update admin password                    |

---

## 🖼 Image Management

All images are stored in `/uploads/` subdirectories:

| Folder             | Used For                          |
|--------------------|-----------------------------------|
| `uploads/products/`| Product images                    |
| `uploads/slider/`  | Hero slider images (optional)     |
| `uploads/icons/`   | Product icon images               |
| `uploads/general/` | Logo, favicon, other              |

Images are uploaded via:
- **Products** → Edit product → Upload image field
- **Site Settings** → Logo upload
- **Media Library** → Bulk uploader with folder selection

---

## 🔒 Security Notes

- Passwords are hashed using `password_hash()` with bcrypt (cost 12)
- All DB queries use PDO prepared statements (SQL injection protected)
- File uploads are restricted to image MIME types and 8MB max
- `config/` directory is blocked via `.htaccess`
- Session-based admin authentication
- **For production:** Disable `display_errors` in `config/db.php` comments

---

## 🌐 Going Live (Production)

1. Upload all files to your web host via FTP/cPanel File Manager
2. Create a MySQL database in cPanel
3. Import `database.sql` via phpMyAdmin
4. Edit `config/db.php`:
   - Update `DB_USER`, `DB_PASS` with your hosting credentials
   - Change `BASE_URL` to your domain: `https://yourdomain.com`
5. Set `uploads/` folder permissions to `755` or `777`
6. Change admin password from the admin panel

---

## 🛠 Customisation Tips

**Add a new product:**
Admin → Products → Add Product → fill form → Save

**Change slider text:**
Admin → Hero Slider → Edit → change Title/Description → Save

**Update company info:**
Admin → Site Settings → update email/phone/address → Save

**Change meta title for a page:**
Each PHP page sets `$pageTitle` and `$pageMeta` at the top — edit directly.

**Add more product categories:**
Admin → Categories → Add Category

---

## 📞 Support

For any setup issues, check:
1. XAMPP Error Log: `C:\xampp\apache\logs\error.log`
2. PHP errors: Add `ini_set('display_errors', 1);` temporarily to `config/db.php`
3. Ensure MySQL is running and database is imported correctly
