diff --git a/.env b/.env
new file mode 100644
index 0000000..82c3514
--- /dev/null
+++ b/.env
@@ -0,0 +1,5 @@
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=local_db
+DB_USERNAME=root
+DB_PASSWORD=password
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fa29567
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+# Agency Lead Generation Website
+
+This project is a simple lead generation website for a medical agency. It includes a public-facing landing page with a contact form to capture leads.
+
+## Project Structure
+
+- `index.php`: The main landing page.
+- `contact_handler.php`: Handles the contact form submission.
+- `lib.php`: Contains helper functions.
+- `assets/`: Contains CSS and JavaScript files.
+ - `css/custom.css`: Custom stylesheets.
+ - `js/main.js`: Custom JavaScript.
+- `db/`: Contains database-related files.
+ - `config.php`: Database configuration and connection.
+ - `migrations/`: Contains database migration files.
+- `.env`: Contains environment variables, including database credentials.
+
+## Setup
+
+1. Create a `.env` file and add your database credentials.
+2. Run the migration scripts in `db/migrations/` to create the necessary tables.
+3. (Optional) Run `db/seed.php` to seed the database with sample data.
diff --git a/assets/css/custom.css b/assets/css/custom.css
new file mode 100644
index 0000000..36c858d
--- /dev/null
+++ b/assets/css/custom.css
@@ -0,0 +1 @@
+/* Custom CSS will go here */
\ No newline at end of file
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100644
index 0000000..f594671
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,62 @@
+document.addEventListener('DOMContentLoaded', function () {
+
+ // Smooth scroll for navigation links
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ const contactForm = document.getElementById('contactForm');
+ const formAlert = document.getElementById('form-alert');
+
+ if (contactForm) {
+ contactForm.addEventListener('submit', function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ if (!contactForm.checkValidity()) {
+ contactForm.classList.add('was-validated');
+ return;
+ }
+
+ const formData = new FormData(contactForm);
+ const submitButton = contactForm.querySelector('button[type="submit"]');
+ const originalButtonText = submitButton.innerHTML;
+
+ submitButton.disabled = true;
+ submitButton.innerHTML = ' Sending...';
+
+ fetch('contact_handler.php', {
+ method: 'POST',
+ body: formData
+ })
+ .then(response => response.json())
+ .then(data => {
+ formAlert.classList.remove('d-none', 'alert-danger', 'alert-success');
+ if (data.success) {
+ formAlert.classList.add('alert-success');
+ formAlert.textContent = data.message;
+ contactForm.reset();
+ contactForm.classList.remove('was-validated');
+ } else {
+ formAlert.classList.add('alert-danger');
+ formAlert.textContent = data.error || 'An unknown error occurred.';
+ }
+ })
+ .catch(error => {
+ formAlert.classList.remove('d-none', 'alert-success');
+ formAlert.classList.add('alert-danger');
+ formAlert.textContent = 'A network error occurred. Please try again.';
+ console.error('Fetch Error:', error);
+ })
+ .finally(() => {
+ submitButton.disabled = false;
+ submitButton.innerHTML = originalButtonText;
+ });
+ });
+ }
+});
\ No newline at end of file
diff --git a/contact_handler.php b/contact_handler.php
new file mode 100644
index 0000000..db563dd
--- /dev/null
+++ b/contact_handler.php
@@ -0,0 +1,58 @@
+ false, 'error' => 'Method Not Allowed']);
+ exit;
+}
+
+$name = $_POST['name'] ?? '';
+$email = $_POST['email'] ?? '';
+$phone = $_POST['phone'] ?? '';
+$message = $_POST['message'] ?? '';
+
+if (empty($name) || empty($email) || empty($message)) {
+ http_response_code(400);
+ echo json_encode(['success' => false, 'error' => 'Please fill in all required fields.']);
+ exit;
+}
+
+if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ http_response_code(400);
+ echo json_encode(['success' => false, 'error' => 'Invalid email format.']);
+ exit;
+}
+
+$pdo = db();
+
+if (!$pdo) {
+ http_response_code(500);
+ echo json_encode(['success' => false, 'error' => 'Database connection failed.']);
+ exit;
+}
+
+try {
+ $stmt = $pdo->prepare("INSERT INTO leads (name, email, phone, message) VALUES (?, ?, ?, ?)");
+ $stmt->execute([$name, $email, $phone, $message]);
+} catch (PDOException $e) {
+ http_response_code(500);
+ error_log('DB Insert Error: ' . $e->getMessage());
+ echo json_encode(['success' => false, 'error' => 'An error occurred while saving your message.']);
+ exit;
+}
+
+$contactEmailResult = MailService::sendContactMessage($name, $email, $message);
+
+if (empty($contactEmailResult['success'])) {
+ // Log the error, but don't block the user. The lead is already saved.
+ error_log("Failed to send contact form email: " . ($contactEmailResult['error'] ?? 'Unknown error'));
+}
+
+
+if (!headers_sent()) {
+ header('Content-Type: application/json');
+}
+echo json_encode(['success' => true, 'message' => 'Thank you for your message! We will get back to you shortly.']);
diff --git a/db/config.php b/db/config.php
index c37fb02..6723641 100644
--- a/db/config.php
+++ b/db/config.php
@@ -1,17 +1,44 @@
PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- ]);
- }
- return $pdo;
+require_once __DIR__ . '/../lib.php';
+
+load_env(__DIR__ . '/../.env');
+
+function db(): ?PDO
+{
+ static $pdo = null;
+
+ if ($pdo !== null) {
+ return $pdo;
+ }
+
+ $host = getenv('DB_HOST');
+ $port = getenv('DB_PORT');
+ $db = getenv('DB_DATABASE');
+ $user = getenv('DB_USERNAME');
+ $pass = getenv('DB_PASSWORD');
+
+ if (!$host || !$db || !$user) {
+ // You could log an error or throw an exception here
+ return null;
+ }
+
+ $dsn = "mysql:host={$host};port={$port};dbname={$db};charset=utf8mb4";
+
+ $options = [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+ ];
+
+ try {
+ $pdo = new PDO($dsn, $user, $pass, $options);
+ return $pdo;
+ } catch (PDOException $e) {
+ // In a real application, you'd log this error and show a generic error page.
+ // For development, it's okay to show the error.
+ // throw new PDOException($e->getMessage(), (int)$e->getCode());
+ error_log('DB Connection Error: ' . $e->getMessage());
+ return null;
+ }
}
diff --git a/db/migrations/001_create_leads_table.sql b/db/migrations/001_create_leads_table.sql
new file mode 100644
index 0000000..ae9330d
--- /dev/null
+++ b/db/migrations/001_create_leads_table.sql
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS leads (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(255) NOT NULL,
+ email VARCHAR(255) NOT NULL,
+ phone VARCHAR(50),
+ message TEXT,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
\ No newline at end of file
diff --git a/index.php b/index.php
index 7205f3d..e3a7157 100644
--- a/index.php
+++ b/index.php
@@ -1,150 +1,210 @@
-
-
+
-
-
- New Style
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ Medical Agency - Your Health is Our Priority
+
+
+
+
+
-
-
-
Analyzing your requirements and generating your website…
-
- Loading…
-
-
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-
This page will update automatically as the plan is implemented.
-
Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
-
-
-
- Page updated: = htmlspecialchars($now) ?> (UTC)
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Our Services
+
Comprehensive support for your medical needs.
+
+
+
+
+
+
+
+
Personalized Treatment Plans
+
Tailored medical strategies designed by top specialists to meet your unique health requirements.
+
+
+
+
+
+
+
+
+
International Client Services
+
Multi-language support and currency options for a hassle-free experience, no matter where you are.
+
+
+
+
+
+
+
+
+
Patient Workflow Management
+
A dedicated CRM to manage your entire treatment journey, from consultation to recovery.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
About MedAgency
+
Founded on the principle of patient-centric care, MedAgency was created to bridge the gap between patients and high-quality medical services worldwide. Our team is dedicated to providing transparent, efficient, and compassionate support throughout your healthcare journey.
+
We leverage cutting-edge technology and a vast network of certified professionals to ensure you receive the best possible care.
+
+
+
+
+
+
+
+
+
+
What Our Patients Say
+
+
+
+
+
+
"The entire process was so smooth and professional. MedAgency took care of everything, and I could focus solely on my recovery."
+
+
+
+
+
+
+
+
"I was amazed by the level of personalized care. The team was always there to answer my questions and support me."
+
+
+
+
+
+
+
+
"Navigating international healthcare seemed daunting, but MedAgency made it simple and stress-free."
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
© MedAgency. All Rights Reserved.
+
+
+
+
+
+
+
+
diff --git a/lib.php b/lib.php
new file mode 100644
index 0000000..2b1b056
--- /dev/null
+++ b/lib.php
@@ -0,0 +1,25 @@
+