From 34806aba5241a96096b96647c721637d0c505c70 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 7 Oct 2025 23:59:11 +0000 Subject: [PATCH] version3 --- .../002_create_donor_profiles_table.sql | 12 +++ donor_dashboard.php | 64 +++++++++++-- donor_profile.php | 96 +++++++++++++++++++ includes/header.php | 17 +++- 4 files changed, 176 insertions(+), 13 deletions(-) create mode 100644 db/migrations/002_create_donor_profiles_table.sql create mode 100644 donor_profile.php diff --git a/db/migrations/002_create_donor_profiles_table.sql b/db/migrations/002_create_donor_profiles_table.sql new file mode 100644 index 0000000..a9180a0 --- /dev/null +++ b/db/migrations/002_create_donor_profiles_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS donor_profiles ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + full_name VARCHAR(255) NOT NULL, + phone VARCHAR(50), + address TEXT, + city VARCHAR(100), + state VARCHAR(100), + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE +); diff --git a/donor_dashboard.php b/donor_dashboard.php index 096f1bb..498ba99 100644 --- a/donor_dashboard.php +++ b/donor_dashboard.php @@ -1,16 +1,64 @@ prepare("SELECT * FROM donor_profiles WHERE user_id = ?"); +$stmt->execute([$user_id]); +$profile = $stmt->fetch(); + +$pageTitle = 'Donor Dashboard'; +include 'includes/header.php'; ?>
-

Welcome, Donor!

-

This is your dashboard. Here you can manage your profile and donations.

- Logout +
+

Welcome, !

+
+ + +
+
+

My Profile

+ Edit Profile +
+
+
+

+ Email:
+ Phone:
+ Address:
+ City:
+ State:
+

+
+
+ +
+

Start a New Donation

+

Ready to make a difference? Click the button below to start a new donation request.

+ New Donation Request +
+ + + + +
- + diff --git a/donor_profile.php b/donor_profile.php new file mode 100644 index 0000000..ff2ec4a --- /dev/null +++ b/donor_profile.php @@ -0,0 +1,96 @@ +prepare("SELECT * FROM donor_profiles WHERE user_id = ?"); +$stmt->execute([$user_id]); +$profile = $stmt->fetch(); + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $full_name = trim($_POST['full_name'] ?? ''); + $phone = trim($_POST['phone'] ?? ''); + $address = trim($_POST['address'] ?? ''); + $city = trim($_POST['city'] ?? ''); + $state = trim($_POST['state'] ?? ''); + + if (empty($full_name)) { + $message = '
Full name is required.
'; + } else { + if ($profile) { + // Update existing profile + $stmt = $pdo->prepare("UPDATE donor_profiles SET full_name = ?, phone = ?, address = ?, city = ?, state = ? WHERE user_id = ?"); + $stmt->execute([$full_name, $phone, $address, $city, $state, $user_id]); + $message = '
Profile updated successfully!
'; + } else { + // Create new profile + $stmt = $pdo->prepare("INSERT INTO donor_profiles (user_id, full_name, phone, address, city, state) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$user_id, $full_name, $phone, $address, $city, $state]); + $message = '
Profile created successfully!
'; + } + // Refresh profile data after insert/update + $stmt = $pdo->prepare("SELECT * FROM donor_profiles WHERE user_id = ?"); + $stmt->execute([$user_id]); + $profile = $stmt->fetch(); + } +} + +$pageTitle = 'My Profile'; +include 'includes/header.php'; +?> + +
+
+
+
+
+

My Profile

+

Manage your personal information.

+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + Back to Dashboard +
+
+
+
+
+
+ + diff --git a/includes/header.php b/includes/header.php index ef4f828..5d55ce4 100644 --- a/includes/header.php +++ b/includes/header.php @@ -38,11 +38,18 @@ Contact - -