diff --git a/_footer.php b/_footer.php new file mode 100644 index 0000000..f7a4e22 --- /dev/null +++ b/_footer.php @@ -0,0 +1,41 @@ + + diff --git a/_header.php b/_header.php new file mode 100644 index 0000000..979c5f7 --- /dev/null +++ b/_header.php @@ -0,0 +1,53 @@ + +
+ +
\ No newline at end of file diff --git a/assets/css/custom.css b/assets/css/custom.css index 2e24ecb..5311005 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -57,3 +57,13 @@ body { font-size: 3rem; color: #007BFF; } + +/* Auth pages styling */ +.choice-card { + transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; +} + +.choice-card:hover { + transform: translateY(-5px); + box-shadow: 0 12px 40px rgba(0,0,0,0.12) !important; +} diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..96dd8cc --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,29 @@ + PDO::ERRMODE_EXCEPTION, + ]); + // Create the database if it doesn't exist + $pdo_admin->exec("CREATE DATABASE IF NOT EXISTS " . DB_NAME); + echo "Database '" . DB_NAME . "' created or already exists.\n"; + + // Now connect to the created database + $pdo = db(); + $migrations = glob(__DIR__ . '/migrations/*.sql'); + sort($migrations); + + foreach ($migrations as $migration) { + echo "Running migration: " . basename($migration) . "...\n"; + $sql = file_get_contents($migration); + $pdo->exec($sql); + echo "Migration successful.\n"; + } + + echo "\nAll migrations completed successfully.\n"; + +} catch (PDOException $e) { + die("Database migration failed: " . $e->getMessage()); +} \ No newline at end of file diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..e2a378c --- /dev/null +++ b/db/migrations/001_create_users_table.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(255) NOT NULL, + last_name VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + user_type ENUM('customer', 'provider') NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/db/migrations/002_create_service_categories_table.sql b/db/migrations/002_create_service_categories_table.sql new file mode 100644 index 0000000..3b1f507 --- /dev/null +++ b/db/migrations/002_create_service_categories_table.sql @@ -0,0 +1,4 @@ +CREATE TABLE IF NOT EXISTS service_categories ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL UNIQUE +); \ No newline at end of file diff --git a/db/migrations/003_create_services_table.sql b/db/migrations/003_create_services_table.sql new file mode 100644 index 0000000..7e7d3db --- /dev/null +++ b/db/migrations/003_create_services_table.sql @@ -0,0 +1,11 @@ +CREATE TABLE IF NOT EXISTS services ( + id INT AUTO_INCREMENT PRIMARY KEY, + provider_id INT NOT NULL, + category_id INT NOT NULL, + name VARCHAR(255) NOT NULL, + description TEXT, + price DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (provider_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (category_id) REFERENCES service_categories(id) +); \ No newline at end of file diff --git a/db/migrations/004_seed_service_categories.sql b/db/migrations/004_seed_service_categories.sql new file mode 100644 index 0000000..cb7cba8 --- /dev/null +++ b/db/migrations/004_seed_service_categories.sql @@ -0,0 +1,7 @@ +INSERT INTO service_categories (name) VALUES +('Pulizie'), +('Riparazioni'), +('Assistenza alla persona'), +('Giardinaggio'), +('Lezioni private'), +('Babysitting'); \ No newline at end of file diff --git a/index.php b/index.php index a88e2d6..3a90696 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,15 @@ +query("SELECT * FROM service_categories ORDER BY name"); + $search_categories = $categories_stmt->fetchAll(); +} catch (PDOException $e) { + $search_categories = []; +} +?> @@ -28,28 +40,17 @@ - -
-
-
- - MeToo - - - - -
- - -
-
-
-
+ + + +
@@ -58,19 +59,21 @@
-
+
-
+
- - + +
-
-
- - -
+
+
@@ -105,48 +108,13 @@
+ - -
- -
+ - -
- -
- - - \ No newline at end of file + diff --git a/login.php b/login.php new file mode 100644 index 0000000..a0f785f --- /dev/null +++ b/login.php @@ -0,0 +1,101 @@ +prepare("SELECT * FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + // Password is correct, start session + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_type'] = $user['user_type']; + $_SESSION['user_name'] = $user['first_name']; + + // Redirect to a logged-in page (e.g., dashboard) + header("Location: index.php"); + exit; + } else { + $error = "Email o password non validi."; + } + } catch (PDOException $e) { + $error = "Errore del database. Riprova più tardi."; + // error_log($e->getMessage()); + } + } +} +?> + + + + + + <?= htmlspecialchars($pageTitle) ?> - MeToo + + + + + + + + + + + + + +
+
+
+
+
+

Accedi

+

Bentornato! Accedi per gestire i tuoi servizi.

+ + + + + + +
+ + +
+
+ + +
+
+ +
+ +
+

Non hai un account? Registrati ora

+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..f83284d --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ +prepare( + "INSERT INTO services (provider_id, category_id, name, description, price) VALUES (?, ?, ?, ?, ?)" + ); + if ($stmt->execute([$provider_id, $category_id, $name, $description, $price])) { + $success = "Servizio aggiunto con successo!"; + } else { + $error = "Errore durante l'aggiunta del servizio."; + } + } catch (PDOException $e) { + $error = "Errore del database: " . $e->getMessage(); + } + } +} + +// Fetch data for the page +try { + $pdo = db(); + // Fetch categories + $categories_stmt = $pdo->query("SELECT * FROM service_categories ORDER BY name"); + $categories = $categories_stmt->fetchAll(); + + // Fetch provider's services + $services_stmt = $pdo->prepare( + "SELECT s.*, sc.name as category_name FROM services s JOIN service_categories sc ON s.category_id = sc.id WHERE s.provider_id = ? ORDER BY s.created_at DESC" + ); + $services_stmt->execute([$provider_id]); + $services = $services_stmt->fetchAll(); +} catch (PDOException $e) { + // Die on critical database error + die("Errore di connessione al database: " . $e->getMessage()); +} + +$pageTitle = "Gestisci Servizi"; +?> +
+

+ + +
+ + +
+ + + +
+
+

Aggiungi un nuovo servizio

+
+
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+

I tuoi servizi

+
+
+ +

Non hai ancora aggiunto nessun servizio.

+ +
+ + + + + + + + + + + + + + + + + + + +
NomeCategoriaPrezzoAzioni
+ Modifica + Elimina +
+
+ +
+
+
+ diff --git a/register.php b/register.php new file mode 100644 index 0000000..a991df5 --- /dev/null +++ b/register.php @@ -0,0 +1,65 @@ + + + + + + + <?= htmlspecialchars($pageTitle) ?> - MeToo + + + + + + + + + + + + + +
+
+

Crea il tuo account

+

Scegli il tipo di profilo più adatto a te.

+
+
+
+
+
+ +

Sono un Cliente

+

Sto cercando un professionista per un servizio a domicilio.

+ +
+
+
+
+
+
+ +

Sono un Fornitore

+

Voglio offrire i miei servizi professionali sulla piattaforma.

+ +
+
+
+
+
+

Hai già un account? Accedi qui.

+
+
+ + + + + + + diff --git a/register_customer.php b/register_customer.php new file mode 100644 index 0000000..1a39bae --- /dev/null +++ b/register_customer.php @@ -0,0 +1,127 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $error = "Un account con questa email esiste già."; + } else { + // Hash the password + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + + // Insert the new user + $insert_stmt = $pdo->prepare( + "INSERT INTO users (first_name, last_name, email, password, user_type) VALUES (?, ?, ?, ?, 'customer')" + ); + if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password])) { + $success = "Registrazione completata! Ora puoi effettuare il login."; + } else { + $error = "Si è verificato un errore durante la registrazione. Riprova."; + } + } + } catch (PDOException $e) { + // In a real app, you would log this error. + $error = "Errore del database. Riprova più tardi."; + // error_log($e->getMessage()); + } + } +} +?> + + + + + + <?= htmlspecialchars($pageTitle) ?> - MeToo + + + + + + + + + + + + + +
+
+
+
+
+

Registrati come Cliente

+

Crea un account per trovare e prenotare servizi in modo facile e veloce.

+ + + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+

Sei un fornitore? Registrati qui.

+

Hai già un account? Accedi.

+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/register_provider.php b/register_provider.php new file mode 100644 index 0000000..cbd55a1 --- /dev/null +++ b/register_provider.php @@ -0,0 +1,126 @@ +prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $error = "Un account con questa email esiste già."; + } else { + // Hash the password + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + + // Insert the new user + $insert_stmt = $pdo->prepare( + "INSERT INTO users (first_name, last_name, email, password, user_type) VALUES (?, ?, ?, ?, 'provider')" + ); + if ($insert_stmt->execute([$first_name, $last_name, $email, $hashed_password])) { + $success = "Registrazione completata! Ora puoi effettuare il login."; + } else { + $error = "Si è verificato un errore durante la registrazione. Riprova."; + } + } + } catch (PDOException $e) { + // In a real app, you would log this error. + $error = "Errore del database. Riprova più tardi."; + // error_log($e->getMessage()); + } + } +} +?> + + + + + + <?= htmlspecialchars($pageTitle) ?> - MeToo + + + + + + + + + + + + + +
+
+
+
+
+

Registrati come Fornitore

+

Crea il tuo account per offrire i tuoi servizi sulla nostra piattaforma.

+ + + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+

Sei un cliente? Registrati qui.

+

Hai già un account? Accedi.

+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/search.php b/search.php new file mode 100644 index 0000000..2d7f336 --- /dev/null +++ b/search.php @@ -0,0 +1,89 @@ +prepare($sql); + $stmt->execute($params); + $results = $stmt->fetchAll(); + +} catch (PDOException $e) { + $error = "Errore del database: " . $e->getMessage(); +} + +require_once '_header.php'; +?> +
+

Ricerca servizi

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

Trovati risultati.

+
+ +
+
+
+
+
+

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

+

+
+

Offerto da:

+ Vedi Dettagli +
+
+
+
+ +
+ + +
+ diff --git a/views/dashboard_customer.php b/views/dashboard_customer.php new file mode 100644 index 0000000..82495be --- /dev/null +++ b/views/dashboard_customer.php @@ -0,0 +1,16 @@ +
+

Ciao, !

+

Benvenuto nella tua dashboard cliente.

+
+
+
+

Le tue prenotazioni

+
+
+

Non hai ancora nessuna prenotazione attiva.

+ Cerca un servizio +
+
+
+
+
\ No newline at end of file diff --git a/views/dashboard_provider.php b/views/dashboard_provider.php new file mode 100644 index 0000000..75eb931 --- /dev/null +++ b/views/dashboard_provider.php @@ -0,0 +1,24 @@ +
+

Ciao, !

+

Benvenuto nella tua dashboard fornitore.

+
+
+
+

Gestisci Servizi

+
+
+

Aggiungi, modifica o rimuovi i servizi che offri.

+ Gestisci i tuoi servizi +
+
+
+
+

Il tuo calendario

+
+
+

La funzionalità calendario sarà disponibile a breve.

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