================================================================ FarmOS — MySQL Server Setup Guide Migrated from: Firebase (Firestore + Firebase Auth) Now uses: MySQL + PHP (compatible with phpMyAdmin) ================================================================ ---------------------------------------------------------------- WHAT CHANGED ---------------------------------------------------------------- BEFORE (Firebase): - Data stored in: Firestore (NoSQL cloud database) - Login via: Firebase Authentication - Real-time sync: Firestore onSnapshot() listeners - Password reset: Firebase email AFTER (MySQL/PHP): - Data stored in: MySQL database (managed via phpMyAdmin) - Login via: PHP session tokens + bcrypt passwords - Real-time sync: Polling every 15–30 seconds - Password reset: Admin resets directly in portal ---------------------------------------------------------------- FILES IN THIS PACKAGE ---------------------------------------------------------------- FarmOS-MySQL.html → Farm app (replaces FarmOS-Firebase.html) FarmOS-Admin-MySQL.html → Admin portal (replaces FarmOS-Admin-Firebase.html) farmos_database.sql → Import this into phpMyAdmin FIRST config/db.php → Edit with your MySQL credentials api/login.php → POST: login, returns session token api/logout.php → POST: logout api/farmdata.php → GET/POST: load & save all farm data api/clients.php → GET/POST: manage clients (admin) api/activity.php → GET/POST: activity log api/recovery.php → POST: password recovery requests api/users.php → GET/POST: users + password change ---------------------------------------------------------------- STEP 1 — Import the Database (phpMyAdmin) ---------------------------------------------------------------- 1. Open phpMyAdmin (usually at http://localhost/phpmyadmin) 2. Click "New" to create a database named: farmos (or the import will create it automatically) 3. Select the "farmos" database 4. Click the "Import" tab 5. Choose file: farmos_database.sql 6. Click "Go" This creates all 7 tables and a default admin user: Email: admin@farmos.local Password: farmos2024 ⚠️ CHANGE THIS after first login! ---------------------------------------------------------------- STEP 2 — Configure db.php ---------------------------------------------------------------- Open config/db.php and edit these 4 lines: define('DB_HOST', 'localhost'); // your MySQL host define('DB_NAME', 'farmos'); // database name define('DB_USER', 'root'); // your MySQL username define('DB_PASS', ''); // your MySQL password For a typical XAMPP/WAMP local setup: DB_HOST = localhost DB_USER = root DB_PASS = (empty) For a hosting provider (shared hosting): DB_HOST = localhost (usually) DB_USER = (your cPanel username)_farmos DB_PASS = (the password you set) ---------------------------------------------------------------- STEP 3 — Set the API_BASE in HTML files ---------------------------------------------------------------- Both HTML files have this at the top of their