diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..544c031 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,32 @@ +body { + font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; +} + +.btn-primary { + background-color: #E53935; + border-color: #E53935; +} + +.btn-primary:hover, .btn-primary:focus, .btn-primary:active { + background-color: #C62828; + border-color: #C62828; +} + +.navbar-dark .navbar-brand { + color: #fff; +} + +.navbar-dark .nav-link.active { + color: #fff; + font-weight: 500; +} + +.card { + border-radius: 0.5rem; + box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); +} + +.modal-header { + background-color: #f8f9fa; + border-bottom: 1px solid #dee2e6; +} diff --git a/db/config.php b/db/config.php index bb98f7d..794426d 100644 --- a/db/config.php +++ b/db/config.php @@ -8,10 +8,21 @@ define('DB_PASS', 'e45f2778-db1f-450c-99c6-29efb4601472'); function db() { static $pdo; if (!$pdo) { - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); + try { + // Connect without specifying a database + $pdo_init = new PDO('mysql:host='.DB_HOST, DB_USER, DB_PASS); + $pdo_init->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + // Create the database if it doesn't exist + $pdo_init->exec("CREATE DATABASE IF NOT EXISTS `".DB_NAME."`"); + + // Now connect to the specific database + $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + } catch (PDOException $e) { + die("DB connection failed: " . $e->getMessage()); + } } return $pdo; } diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..69ec5ed --- /dev/null +++ b/db/setup.php @@ -0,0 +1,24 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $sql = "CREATE TABLE IF NOT EXISTS leads ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + company VARCHAR(255), + email VARCHAR(255) NOT NULL, + message TEXT, + status VARCHAR(50) DEFAULT 'New', + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + )"; + + $pdo->exec($sql); + + echo "Database setup complete. Table 'leads' created successfully."; + +} catch (PDOException $e) { + die("Database setup failed: " . $e->getMessage()); +} diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..bb77a69 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..5d98e3a --- /dev/null +++ b/includes/header.php @@ -0,0 +1,40 @@ + + + + + + Zamba crm + + + + + + + + + + + + + + + + + + + +
diff --git a/leads.php b/leads.php new file mode 100644 index 0000000..f0a5755 --- /dev/null +++ b/leads.php @@ -0,0 +1,158 @@ +prepare($sql); + $stmt->execute([ + ':name' => $name, + ':email' => $email, + ':company' => $company, + ':message' => $message + ]); + + $_SESSION['success_message'] = 'Lead added successfully!'; + header("Location: leads.php"); + exit; + + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } + // If there are errors, the script will continue and display them below +} + +try { + $pdo = db(); + $stmt = $pdo->query("SELECT id, name, company, email, status, created_at FROM leads ORDER BY created_at DESC"); + $leads = $stmt->fetchAll(); +} catch (PDOException $e) { + die("Could not fetch leads: " . $e->getMessage()); +} + +require_once 'includes/header.php'; +?> + + + + + + +
+ Error! Please correct the following issues: + +
+ + + +
+
+

Leads

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameCompanyEmailStatusDate
No leads found. Add one to get started!
+
+
+
+ + + + +