diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..7b72507 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,21 @@ + + + +
+
+
+

Dashboard

+

Welcome, !

+

This is your dashboard. More features will be added soon.

+
+
+
+ + \ No newline at end of file diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..074e173 --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,18 @@ +exec($sql); + echo "Migration from $file executed successfully.\n"; + } + +} catch (PDOException $e) { + die("Database migration failed: " . $e->getMessage()); +} + diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..357589d --- /dev/null +++ b/db/migrations/001_create_users_table.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index acde56f..0e97043 100644 --- a/index.php +++ b/index.php @@ -1,46 +1,4 @@ - - - - - - FoodBridge - Connecting NGOs and Restaurants - - - - - - - - - - - - - - - - - - - - - - +
@@ -85,7 +43,7 @@

For NGOs

Access a steady stream of quality food donations from local restaurants. Reduce your operational costs, expand your reach, and focus on what you do best: serving the community.

- Register your NGO + Register your NGO
A smiling volunteer from an NGO receiving a food donation. @@ -100,7 +58,7 @@

For Restaurants

Reduce food waste, gain tax benefits, and build a positive brand image. Donating your surplus food is simple, efficient, and makes a tangible impact in your local community.

- Register your Restaurant + Register your Restaurant
A chef plating food in a restaurant kitchen, representing food donation. @@ -135,16 +93,4 @@ - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..c6f9dec --- /dev/null +++ b/login.php @@ -0,0 +1,71 @@ +prepare("SELECT * FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + session_start(); + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_email'] = $user['email']; + header("Location: dashboard.php"); + exit; + } else { + $errors[] = 'Invalid email or password'; + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} +?> + + +
+
+
+

Login

+ + +
+ +

+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..321e610 --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/partials/footer.php b/partials/footer.php new file mode 100644 index 0000000..73e1de5 --- /dev/null +++ b/partials/footer.php @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/partials/header.php b/partials/header.php new file mode 100644 index 0000000..4e529b4 --- /dev/null +++ b/partials/header.php @@ -0,0 +1,52 @@ + + + + + + + FoodBridge - Connecting NGOs and Restaurants + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/signup.php b/signup.php new file mode 100644 index 0000000..2be4b90 --- /dev/null +++ b/signup.php @@ -0,0 +1,89 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $errors[] = 'Email already exists'; + } else { + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + + $stmt = $pdo->prepare("INSERT INTO users (email, password) VALUES (?, ?)"); + $stmt->execute([$email, $hashed_password]); + + $success = 'Registration successful! You can now login.'; + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} +?> + + +
+
+
+

Sign Up

+ + +
+ +

+ +
+ + + +
+

+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+
+ + \ No newline at end of file