From 69bd25e48adc05e9f6ba039ec5a52d4ffdadd119 Mon Sep 17 00:00:00 2001 From: Geemiinii Date: Tue, 7 Apr 2026 23:25:59 +0200 Subject: [PATCH 1/5] 404, account and home setup setup of the 3 php files, added redirection in index.php to send user in home.php directly --- env | 13 +++++++++++++ src/app/views/404.php | 6 ++++++ src/app/views/account.php | 1 + src/app/views/home.php | 2 ++ src/public/index.php | 11 ++++++++++- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 env create mode 100644 src/app/views/404.php create mode 100644 src/app/views/account.php create mode 100644 src/app/views/home.php diff --git a/env b/env new file mode 100644 index 0000000..d5f07d7 --- /dev/null +++ b/env @@ -0,0 +1,13 @@ +# MySQL .env variables +# Credentials to establish a connection to a given DB +MYSQL_HOST=mysql +MYSQL_PORT=3306 +MYSQL_DATABASE=efes_db +MYSQL_USER= +MYSQL_PASSWORD= +MYSQL_ROOT_PASSWORD= + +# Docker ports +DOCKER_PORT_MYSQL=3306 +DOCKER_PORT_PHP=8080 +DOCKER_PORT_PMA=8081 diff --git a/src/app/views/404.php b/src/app/views/404.php new file mode 100644 index 0000000..b6b0593 --- /dev/null +++ b/src/app/views/404.php @@ -0,0 +1,6 @@ +
+
+

404

+

Page not found

+
+
diff --git a/src/app/views/account.php b/src/app/views/account.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/src/app/views/account.php @@ -0,0 +1 @@ +Home page + diff --git a/src/public/index.php b/src/public/index.php index 3d5fc93..91175ca 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -9,5 +9,14 @@ if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } + echo "Connected to MySQL successfully!"; -?> \ No newline at end of file + + +//redirect to home page in view folder +require_once __DIR__ . '/../app/views/home.php'; + + +?> + + From d63a9578cd39797050777eafdb22aa7137c738e5 Mon Sep 17 00:00:00 2001 From: Geemiinii Date: Wed, 8 Apr 2026 11:12:17 +0200 Subject: [PATCH 2/5] further work on 404, home adjusted default path to home.php, added header.php and navbar.php to put on all pages for improved navigation --- src/app/controllers/HomeController.php | 7 ++++ src/app/models/account.php | 15 +++++++ src/app/views/404.php | 1 + src/app/views/account.php | 1 - src/app/views/account_view.php | 2 + src/app/views/home.php | 7 ++++ src/app/views/partials/header.php | 7 ++++ src/app/views/partials/navbar.php | 25 ++++++++++++ src/public/index.php | 55 +++++++++++++++++--------- src/routes/web.php | 8 ++++ 10 files changed, 109 insertions(+), 19 deletions(-) create mode 100644 src/app/controllers/HomeController.php create mode 100644 src/app/models/account.php delete mode 100644 src/app/views/account.php create mode 100644 src/app/views/account_view.php create mode 100644 src/app/views/partials/header.php create mode 100644 src/app/views/partials/navbar.php diff --git a/src/app/controllers/HomeController.php b/src/app/controllers/HomeController.php new file mode 100644 index 0000000..37ab79b --- /dev/null +++ b/src/app/controllers/HomeController.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/app/views/404.php b/src/app/views/404.php index b6b0593..291663f 100644 --- a/src/app/views/404.php +++ b/src/app/views/404.php @@ -1,3 +1,4 @@ +

404

diff --git a/src/app/views/account.php b/src/app/views/account.php deleted file mode 100644 index b3d9bbc..0000000 --- a/src/app/views/account.php +++ /dev/null @@ -1 +0,0 @@ - + diff --git a/src/app/views/home.php b/src/app/views/home.php index 1a6aa31..626c864 100644 --- a/src/app/views/home.php +++ b/src/app/views/home.php @@ -1,2 +1,9 @@ + + +

Bienvenue a EFES KEBAB

+
Home page
+

Découvrez nos plats savoureux !

+ +

mettre horaire, photos, etc...

\ No newline at end of file diff --git a/src/app/views/partials/header.php b/src/app/views/partials/header.php new file mode 100644 index 0000000..8636dd3 --- /dev/null +++ b/src/app/views/partials/header.php @@ -0,0 +1,7 @@ + + + + + <?php echo isset($title) ? $title : "EFES KEBAB"; ?> + + \ No newline at end of file diff --git a/src/app/views/partials/navbar.php b/src/app/views/partials/navbar.php new file mode 100644 index 0000000..b127b8e --- /dev/null +++ b/src/app/views/partials/navbar.php @@ -0,0 +1,25 @@ + + + \ No newline at end of file diff --git a/src/public/index.php b/src/public/index.php index 91175ca..5d997ad 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -1,22 +1,41 @@ connect_error) { - die("Connection failed: " . $conn->connect_error); -} - -echo "Connected to MySQL successfully!"; - -//redirect to home page in view folder -require_once __DIR__ . '/../app/views/home.php'; - - -?> +$routes = require_once __DIR__ . "/../routes/web.php"; +function normalize_path($path) { + return '/' . trim($path, '/'); +} +$method = $_SERVER['REQUEST_METHOD']; +$uri = $_SERVER['REQUEST_URI']; + +$path = parse_url($uri, PHP_URL_PATH); +$request = normalize_path(isset($path) ? $path : '/'); + +$viewDir = '/../app/views/'; +$controllerDir = '/../app/controllers/'; + +if (isset($routes[$method][$request])) { + $controllerInfo = $routes[$method][$request]; + $controllerName = $controllerInfo[0]; + $controllerAction = $controllerInfo[1]; + + $controllerFile = __DIR__ . $controllerDir . $controllerName . '.php'; + if (file_exists($controllerFile)) { + require_once $controllerFile; + + $controller = new $controllerName(); + if (method_exists($controller, $controllerAction)) { + $controller->$controllerAction(); + } else { + http_response_code(500); + echo "Action $controllerAction in $controllerName is undefined!"; + } + } else { + http_response_code(500); + echo "Controller $controllerName does not exist!"; + } +} else { + http_response_code(404); + require __DIR__ . $viewDir . "404.php"; +} \ No newline at end of file diff --git a/src/routes/web.php b/src/routes/web.php index b3d9bbc..ef05717 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -1 +1,9 @@ [ + '/' => ['HomeController', 'home'], + ], + 'POST' => [ + + ], +]; \ No newline at end of file From 704f024f6bba7803fcee87305244e4e07240d7fc Mon Sep 17 00:00:00 2001 From: William Le Gallou Date: Wed, 8 Apr 2026 14:46:10 +0200 Subject: [PATCH 3/5] Sign-in, sign-up and HTML partials done. Needs testing --- src/app/controllers/sign-in.php | 30 ++++++++++++++++++++++++++ src/app/controllers/sign-up.php | 25 ++++++++++++++++++++++ src/app/models/account.php | 13 ++++++++++++ src/app/views/partials/footer.php | 2 ++ src/app/views/partials/header.php | 8 +++++++ src/app/views/partials/nav.php | 14 +++++++++++++ src/app/views/sign-in.php | 16 ++++++++++++++ src/app/views/sign-up.php | 35 +++++++++++++++++++++++++++++++ 8 files changed, 143 insertions(+) create mode 100644 src/app/controllers/sign-in.php create mode 100644 src/app/controllers/sign-up.php create mode 100644 src/app/models/account.php create mode 100644 src/app/views/partials/footer.php create mode 100644 src/app/views/partials/header.php create mode 100644 src/app/views/partials/nav.php create mode 100644 src/app/views/sign-in.php create mode 100644 src/app/views/sign-up.php diff --git a/src/app/controllers/sign-in.php b/src/app/controllers/sign-in.php new file mode 100644 index 0000000..e6a4d01 --- /dev/null +++ b/src/app/controllers/sign-in.php @@ -0,0 +1,30 @@ +prepare('SELECT * FROM account WHERE email = :email'); +$query->execute(['email' => $email]); +$account = $query->fetchObject(Account::class); + +if(!$account) { + header('Location: /sign-in?error=2'); +} else if(!password_verify($password, $account->password)) { + header('Location: /sign-in?error=3'); +} else { + session_start(); + $_SESSION['account'] = $account; + //header('Location: /accueil'); +} diff --git a/src/app/controllers/sign-up.php b/src/app/controllers/sign-up.php new file mode 100644 index 0000000..836e12f --- /dev/null +++ b/src/app/controllers/sign-up.php @@ -0,0 +1,25 @@ +prepare('INSERT INTO account (first_name, last_name, phone, email, password, date_creation, role) VALUES (?, ?, ?, ?, ?, ?, ?)'); +$query->execute([$first_name, $last_name, $phone, $email, password_hash($password, PASSWORD_DEFAULT), date("Y-m-d"), 1]); + +header('Location: /sign-in'); \ No newline at end of file diff --git a/src/app/models/account.php b/src/app/models/account.php new file mode 100644 index 0000000..d0b4d50 --- /dev/null +++ b/src/app/models/account.php @@ -0,0 +1,13 @@ + + \ No newline at end of file diff --git a/src/app/views/partials/header.php b/src/app/views/partials/header.php new file mode 100644 index 0000000..9a7c691 --- /dev/null +++ b/src/app/views/partials/header.php @@ -0,0 +1,8 @@ + + + + + <?= $title ?? "Efes Resto Kebab" ?> + + + \ No newline at end of file diff --git a/src/app/views/partials/nav.php b/src/app/views/partials/nav.php new file mode 100644 index 0000000..e234e3b --- /dev/null +++ b/src/app/views/partials/nav.php @@ -0,0 +1,14 @@ + + diff --git a/src/app/views/sign-in.php b/src/app/views/sign-in.php new file mode 100644 index 0000000..1677096 --- /dev/null +++ b/src/app/views/sign-in.php @@ -0,0 +1,16 @@ + +
+

Sign in

+
+
+ + +
+
+ + +
+ +
+
+ diff --git a/src/app/views/sign-up.php b/src/app/views/sign-up.php new file mode 100644 index 0000000..db1c55f --- /dev/null +++ b/src/app/views/sign-up.php @@ -0,0 +1,35 @@ + +
+

Sign up

+
+
+
+ + +
+
+ + +
+
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ From 6526023b26867979cdcc76a9fcd4de68a4059dcf Mon Sep 17 00:00:00 2001 From: Geemiinii Date: Wed, 8 Apr 2026 16:02:48 +0200 Subject: [PATCH 4/5] marcel --- env | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 env diff --git a/env b/env deleted file mode 100644 index d5f07d7..0000000 --- a/env +++ /dev/null @@ -1,13 +0,0 @@ -# MySQL .env variables -# Credentials to establish a connection to a given DB -MYSQL_HOST=mysql -MYSQL_PORT=3306 -MYSQL_DATABASE=efes_db -MYSQL_USER= -MYSQL_PASSWORD= -MYSQL_ROOT_PASSWORD= - -# Docker ports -DOCKER_PORT_MYSQL=3306 -DOCKER_PORT_PHP=8080 -DOCKER_PORT_PMA=8081 From 2d444b593d2c8384c9fb4c83a770699c571f2b77 Mon Sep 17 00:00:00 2001 From: Geemiinii Date: Wed, 8 Apr 2026 22:15:57 +0200 Subject: [PATCH 5/5] Finished account page + last adjustment finished to implement the account page : it allows users to see all their information : they can't modify for now. The navbar is functionnal : you can access sign-in, sign-up and home without any problem. Every page should be working WARNING : since i don't know how to route controllers pages, i did not test all the pages. --- src/app/controllers/HomeController.php | 11 ++++++++++ src/app/views/404.php | 1 + src/app/views/account_view.php | 28 ++++++++++++++++++++++++++ src/app/views/home.php | 4 +++- src/app/views/partials/nav.php | 2 +- src/app/views/partials/navbar.php | 8 ++++---- src/routes/web.php | 5 ++++- 7 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/app/controllers/HomeController.php b/src/app/controllers/HomeController.php index 37ab79b..5247f8e 100644 --- a/src/app/controllers/HomeController.php +++ b/src/app/controllers/HomeController.php @@ -4,4 +4,15 @@ public function home() { require_once __DIR__ . '/../views/home.php'; } + public function viewSignIn() { + require_once __DIR__ . '/../views/sign-in.php'; + } + + public function viewSignUp() { + require_once __DIR__ . '/../views/sign-up.php'; + } + + public function viewAccount() { + require_once __DIR__ . '/../views/account_view.php'; + } } \ No newline at end of file diff --git a/src/app/views/404.php b/src/app/views/404.php index 291663f..2bc380d 100644 --- a/src/app/views/404.php +++ b/src/app/views/404.php @@ -5,3 +5,4 @@

Page not found

+ diff --git a/src/app/views/account_view.php b/src/app/views/account_view.php index 63baf9f..f568932 100644 --- a/src/app/views/account_view.php +++ b/src/app/views/account_view.php @@ -1,2 +1,30 @@ + +
+

Mon compte

+ +
+ + diff --git a/src/app/views/home.php b/src/app/views/home.php index 626c864..91f921b 100644 --- a/src/app/views/home.php +++ b/src/app/views/home.php @@ -6,4 +6,6 @@

Découvrez nos plats savoureux !

-

mettre horaire, photos, etc...

\ No newline at end of file +

mettre horaire, photos, etc...

+ + diff --git a/src/app/views/partials/nav.php b/src/app/views/partials/nav.php index e234e3b..a72ca70 100644 --- a/src/app/views/partials/nav.php +++ b/src/app/views/partials/nav.php @@ -10,5 +10,5 @@ } ?> diff --git a/src/app/views/partials/navbar.php b/src/app/views/partials/navbar.php index b127b8e..9f5685f 100644 --- a/src/app/views/partials/navbar.php +++ b/src/app/views/partials/navbar.php @@ -1,10 +1,10 @@ @@ -12,7 +12,7 @@
  • Home
  • - +
  • Commander
  • Mon compte
  • Mon panier
  • diff --git a/src/routes/web.php b/src/routes/web.php index ef05717..f85cad4 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -1,7 +1,10 @@ [ - '/' => ['HomeController', 'home'], + '/' => ['HomeController', 'home'], + '/sign-in' => ['HomeController', 'viewSignIn'], + '/sign-up' => ['HomeController', 'viewSignUp'], + '/account' => ['HomeController', 'viewAccount'], ], 'POST' => [