From 1b9afa40ef904f9b7bc6ebd905272fb1f5bd6557 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 29 Oct 2025 10:45:26 +0000 Subject: [PATCH] v4 --- assets/css/custom.css | 33 +++- .../005_add_location_to_users_table.sql | 1 + index.php | 21 +-- register_provider.php | 11 +- search.php | 177 ++++++++++-------- service.php | 137 ++++++++++++++ 6 files changed, 282 insertions(+), 98 deletions(-) create mode 100644 db/migrations/005_add_location_to_users_table.sql create mode 100644 service.php diff --git a/assets/css/custom.css b/assets/css/custom.css index 5311005..8f70b14 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -20,7 +20,7 @@ body { left: 0; right: 0; bottom: 0; - background: linear-gradient(45deg, rgba(0, 123, 255, 0.8), rgba(40, 167, 69, 0.8)); + background: linear-gradient(45deg, rgba(32, 222, 110, 0.8), rgba(40, 167, 69, 0.8)); } .hero-section .container { @@ -37,16 +37,16 @@ body { } .btn-primary { - background-color: #007BFF; - border-color: #007BFF; + background-color: #20de6e; + border-color: #20de6e; padding: 0.75rem 1.5rem; border-radius: 0.5rem; font-weight: 600; } .btn-primary:hover { - background-color: #0056b3; - border-color: #0056b3; + background-color: #18b35a; + border-color: #18b35a; } .how-it-works { @@ -55,7 +55,7 @@ body { .step-icon { font-size: 3rem; - color: #007BFF; + color: #20de6e; } /* Auth pages styling */ @@ -67,3 +67,24 @@ body { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(0,0,0,0.12) !important; } + +.text-primary { + color: #20de6e !important; +} + +.btn-outline-primary { + --bs-btn-color: #20de6e; + --bs-btn-border-color: #20de6e; + --bs-btn-hover-color: #fff; + --bs-btn-hover-bg: #20de6e; + --bs-btn-hover-border-color: #20de6e; + --bs-btn-active-color: #fff; + --bs-btn-active-bg: #20de6e; + --bs-btn-active-border-color: #20de6e; + --bs-btn-disabled-color: #20de6e; + --bs-btn-disabled-bg: transparent; +} + +.navbar-toggler-icon { + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(32, 222, 110, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e"); +} \ No newline at end of file diff --git a/db/migrations/005_add_location_to_users_table.sql b/db/migrations/005_add_location_to_users_table.sql new file mode 100644 index 0000000..a55d949 --- /dev/null +++ b/db/migrations/005_add_location_to_users_table.sql @@ -0,0 +1 @@ +ALTER TABLE `users` ADD `location` VARCHAR(255) NULL DEFAULT NULL AFTER `user_type`; diff --git a/index.php b/index.php index 3a90696..a1eaf16 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,5 @@ query("SELECT * FROM service_categories ORDER BY name"); - $search_categories = $categories_stmt->fetchAll(); -} catch (PDOException $e) { - $search_categories = []; -} ?> @@ -68,12 +59,10 @@ try {
- +
+ + +
@@ -117,4 +106,4 @@ try { - + \ No newline at end of file diff --git a/register_provider.php b/register_provider.php index cbd55a1..1e0b14c 100644 --- a/register_provider.php +++ b/register_provider.php @@ -9,6 +9,7 @@ $success = null; if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = trim($_POST['name'] ?? ''); $email = trim($_POST['email'] ?? ''); + $location = trim($_POST['location'] ?? ''); $password = $_POST['password'] ?? ''; $confirm_password = $_POST['confirm_password'] ?? ''; @@ -17,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $first_name = $name_parts[0]; $last_name = $name_parts[1] ?? ''; - if (empty($first_name) || empty($email) || empty($password)) { + if (empty($first_name) || empty($email) || empty($password) || empty($location)) { $error = "Tutti i campi sono obbligatori."; } elseif ($password !== $confirm_password) { $error = "Le password non coincidono."; @@ -37,9 +38,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Insert the new user $insert_stmt = $pdo->prepare( - "INSERT INTO users (first_name, last_name, email, password, user_type) VALUES (?, ?, ?, ?, 'provider')" + "INSERT INTO users (first_name, last_name, email, password, user_type, location) VALUES (?, ?, ?, ?, 'provider', ?)" ); - if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password])) { + if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password, $location])) { $success = "Registrazione completata! Ora puoi effettuare il login."; } else { $error = "Si è verificato un errore durante la registrazione. Riprova."; @@ -95,6 +96,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
+ + +
diff --git a/search.php b/search.php index 2d7f336..983ed2f 100644 --- a/search.php +++ b/search.php @@ -1,89 +1,120 @@ prepare($sql); + $stmt->execute($params); + $results = $stmt->fetchAll(); + + } catch (PDOException $e) { + // In a real app, you would log this error. + $error_message = "Si è verificato un errore durante la ricerca. Riprova più tardi."; } - - if (!empty($category_id)) { - $sql .= " AND s.category_id = ?"; - $params[] = $category_id; - } - - $stmt = $pdo->prepare($sql); - $stmt->execute($params); - $results = $stmt->fetchAll(); - -} catch (PDOException $e) { - $error = "Errore del database: " . $e->getMessage(); } -require_once '_header.php'; ?> -
-

Ricerca servizi

+ + + + + + Risultati della Ricerca - MeToo + + + + + -
-
-
-
- -
-
- -
-
+ + +
+

Risultati della ricerca

+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
-
- -
- -
Nessun servizio trovato per la tua ricerca.
- -

Trovati risultati.

-
- -
-
-
-
-
-

100 ? '...' : '') ?>

-

-
-

Offerto da:

- Vedi Dettagli + +
+ +
+ Nessun servizio trovato per "" . Prova a modificare i criteri di ricerca. +
+ +

Trovati risultati.

+
+ +
+
+
+
+
+

...

+

+ Prezzo:
+ Fornitore:
+ Comune: +

+ Vedi Dettagli
-
- -
- + +
+ -
- + + + + + + + + \ No newline at end of file diff --git a/service.php b/service.php new file mode 100644 index 0000000..32bfdc2 --- /dev/null +++ b/service.php @@ -0,0 +1,137 @@ +prepare($sql); + $stmt->execute([':service_id' => $service_id]); + $service = $stmt->fetch(); + + if ($service) { + // Fetch other providers offering a service with the same name in the same location + $sql_others = " + SELECT + u.first_name, + u.last_name, + u.location, + s.price + FROM services s + JOIN users u ON s.provider_id = u.id + WHERE s.name = :service_name + AND u.location = :location + AND s.id != :service_id + AND u.user_type = 'provider' + ORDER BY s.price ASC + "; + $stmt_others = $pdo->prepare($sql_others); + $stmt_others->execute([ + ':service_name' => $service['name'], + ':location' => $service['location'], + ':service_id' => $service_id + ]); + $other_providers = $stmt_others->fetchAll(); + } + +} catch (PDOException $e) { + $error_message = "Si è verificato un errore. Riprova più tardi."; + // In a real app, you would log this error: error_log($e->getMessage()); +} + +$pageTitle = $service ? htmlspecialchars($service['name']) : "Servizio non trovato"; +$pageDescription = $service ? htmlspecialchars(substr($service['description'], 0, 155)) : ""; + +?> + + + + + + <?= $pageTitle ?> - MeToo + + + + + + + + + +
+ +
+ +
Servizio non trovato.
+ +
+
+
+
+

+
+

+
+

+ Prezzo:
+ Fornitore:
+ Comune: +

+
+
+
+
+
+
+
Migliori fornitori in zona
+ +

Nessun altro fornitore trovato in questa zona per questo servizio.

+ +
    + +
  • + + +
  • + +
+ +
+
+
+
+ +
+ + + + + + +