What I prepared (ready to use right away)
Below you’ll find:
1. a Replit AI prompt ready to paste,
2. .env template,
3. secure MySQL user / GRANT SQL to run on your DB server,
4. import script examples (mysql CLI and PHP alternative),
5. PHP PDO connection template (multi-database, env-driven),
6. suggested endpoints / mapping to your existing pages (which DB each page should
read from),
7. safety & testing checklist for deployment on Replit.
Use this now if you want the quickest, safest integration.
1) Ready-to-paste Replit AI / Engineer prompt:
Context:
- I have six phpMyAdmin .sql dumps already uploaded to the project files:
1) u360243454_admin_panel.sql
2) u360243454_career.sql
3) u360243454_contact.sql
4) u360243454_erp_software.sql
5) u360243454_subscribe.sql
6) u360243454_subscribe_page.sql
Goal:
Integrate these six existing MySQL datasets into the running CRM with minimal
changes to UI, add a safe single DB user for the app, and expose data via current
PHP modules.
Tasks:
1. Use a managed MySQL instance (recommended for Replit). Add environment
variables: DB_HOST, DB_PORT, DB_ADMIN_USER, DB_ADMIN_PASS, APP_DB_USER,
APP_DB_PASS. Provide fallback to local socket if available.
2. Create six databases with exact dump names above and import SQL dumps intact.
3. Create a single app DB user `app_user` with a strong randomly-generated password
and grant it SELECT/INSERT/UPDATE/DELETE on all six databases only (see SQL below).
4. Add `vlucas/phpdotenv` to the PHP project to load `.env`. Create
`.env.template`.
5. Add a db connection library file `config/db.php` that:
- uses PDO
- reads credentials from environment
- provides a helper `getPDO($dbname)` to connect to a given database
- uses prepared statements and sets PDO::ERRMODE_EXCEPTION
6. Update the following pages to use `getPDO()` mapped to appropriate DBs:
- profile.php -> u360243454_career + u360243454_contact
- view-tickets.php -> u360243454_admin_panel or u360243454_erp_software (ticket
source)
- get-quote.php -> u360243454_subscribe / subscribe_page
- lead generation pages -> u360243454_contact / u360243454_career
- manage-surveyorform.php -> u360243454_erp_software
- customer.php -> u360243454_contact
- user_task.php, task.php, manage_timesheet.php -> u360243454_erp_software
- sended_message.php & recieved_message.php -> u360243454_admin_panel
- view-complaints.php -> u360243454_admin_panel
- change-password.php -> update admin table in u360243454_admin_panel (use
hashed password)
7. Add a one-off script `scripts/import_all.sh` that imports all .sql files into
the new databases using `mysql` CLI and environment admin creds.
8. Add a `scripts/create_app_user.sql` to create `app_user` and GRANT privileges.
9. Add an admin-only page `admin/db-status.php` showing the row counts for each
top-level table for quick verification.
10. Document steps in README: how to set env, how to re-import dumps, how to rotate
app_user password, how to rollback.
11. Hardening: convert existing plaintext password storage into password hashes
(bcrypt) in migration script; do not migrate plaintext passwords live until you add
login reset flow. Add CSRF tokens to forms and escape output.
Deliverables:
- Updated repo files included in the Replit project:
- .env.template
- config/db.php
- scripts/import_all.sh
- scripts/create_app_user.sql
- admin/db-status.php
- README.md with run & rollback steps.
2) .env.template (paste into project root):
# Use a managed MySQL (hostname or socket)
DB_ADMIN_HOST=your-admin-db-host.example.com
DB_ADMIN_PORT=3306
DB_ADMIN_USER=root
DB_ADMIN_PASS=SECRET_ADMIN_PASS
# App (least privilege) credentials (created by create_app_user.sql)
APP_DB_USER=app_user
APP_DB_PASS=REPLACE_WITH_GENERATED_PASSWORD
# Default charset
DB_CHARSET=utf8mb4
3) SQL to create app_user and grant privileges
Run on your database admin connection (replace placeholders):
-- run as admin user
CREATE USER IF NOT EXISTS 'app_user'@'%' IDENTIFIED BY 'STRONG_PASSWORD_GOES_HERE';
-- restrict to only needed privileges; avoid GRANT ALL
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_admin_panel`.* TO
'app_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_career`.* TO 'app_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_contact`.* TO 'app_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_erp_software`.* TO
'app_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_subscribe`.* TO 'app_user'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `u360243454_subscribe_page`.* TO
'app_user'@'%';
FLUSH PRIVILEGES;
Note: Replace '%' with your Replit IPs or host for better security, or use SSL/TLS.
4) Import script examples
#!/usr/bin/env bash
# expects DB_ADMIN_* env vars set
set -euo pipefail
SQL_DIR="./" # adjust to where dumps are
for f in u360243454_*.sql; do
dbname=$(basename "$f" .sql)
echo "Creating database $dbname..."
mysql -h "$DB_ADMIN_HOST" -P "$DB_ADMIN_PORT" -u "$DB_ADMIN_USER" -
p"$DB_ADMIN_PASS" -e "CREATE DATABASE IF NOT EXISTS \`$dbname\` DEFAULT CHARACTER
SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
echo "Importing $f into $dbname..."
mysql -h "$DB_ADMIN_HOST" -P "$DB_ADMIN_PORT" -u "$DB_ADMIN_USER" -
p"$DB_ADMIN_PASS" "$dbname" < "$SQL_DIR/$f"
done
echo "Done"
5) PHP DB connection helper (create config/db.php)
<?php
require_once __DIR__ . '/../vendor/autoload.php'; // if using phpdotenv
use Dotenv\Dotenv;
$root = dirname(__DIR__);
if (file_exists($root . '/.env')) {
$dotenv = Dotenv::createImmutable($root);
$dotenv->load();
}
function getPDO(string $database) : PDO {
$host = getenv('DB_ADMIN_HOST') ?: '127.0.0.1';
$port = getenv('DB_ADMIN_PORT') ?: '3306';
$user = getenv('APP_DB_USER') ?: 'app_user';
$pass = getenv('APP_DB_PASS') ?: '';
$charset = getenv('DB_CHARSET') ?: 'utf8mb4';
$dsn = "mysql:host={$host};port={$port};dbname={$database};charset={$charset}";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
return new PDO($dsn, $user, $pass, $options);
}