Use this if you cannot connect to MySQL. SQLite is a file-based database that doesn't require MySQL.
Create config/database_sqlite.php:
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
// SQLite Configuration
define('DB_TYPE', 'sqlite');
define('DB_FILE', dirname(__DIR__) . '/database/email_service.db');
define('SITE_URL', 'https://ds.skprotik.com/email-service/');
// Create database directory if not exists
if (!file_exists(dirname(DB_FILE))) {
mkdir(dirname(DB_FILE), 0777, true);
}
function getDB() {
try {
$db = new SQLite3(DB_FILE);
$db->busyTimeout(5000);
// Enable foreign keys
$db->exec('PRAGMA foreign_keys = ON');
return $db;
} catch (Exception $e) {
die("SQLite Error: " . $e->getMessage());
}
}
function sanitize($input) {
if (is_array($input)) {
foreach($input as $key => $value) {
$input[$key] = sanitize($value);
}
} else {
$input = trim($input);
$input = stripslashes($input);
$input = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
}
return $input;
}
function isLoggedIn() {
return isset($_SESSION['user_id']);
}
function redirect($url) {
header("Location: " . $url);
exit();
}
?>
Change the first line of your PHP files from:
require_once 'config/database.php';
To:
require_once 'config/database_sqlite.php';