Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/app/controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
class HomeController {
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';
}
}
30 changes: 30 additions & 0 deletions src/app/controllers/sign-in.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require __DIR__ .'/../models/account.php';
require __DIR__ .'/../../config/database.php';

$email = $_REQUEST["email"];
$password = $_REQUEST["password"];

if(empty($_POST["email"])) {
http_response_code(400);
header('Location: /sign-in.php?error=1');
}
if(empty($_POST["password"])) {
http_response_code(400);
header('Location: /sign-in?error=1');
}

$query = getConnection()->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');
}
25 changes: 25 additions & 0 deletions src/app/controllers/sign-up.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require __DIR__ .'/../models/account.php';
require __DIR__ .'/../../config/database.php';

$first_name = $_REQUEST["first_name"];
$last_name = $_REQUEST["last_name"];
$phone = $_REQUEST["phone"];
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];

if (
empty($_POST["first_name"]) ||
empty($_POST["last_name"]) ||
empty($_POST["phone"]) ||
empty($_POST["email"]) ||
empty($_POST["password"])) {
http_response_code(400);
header('Location: /sign-up?error=1');
}

$query = getConnection()->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');
15 changes: 15 additions & 0 deletions src/app/models/account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class Account
{
public $id;
public $first_name;
public $last_name;
public $email;
public $phone;
public $password;
public $date_creation;
public $role_id;
}

?>
8 changes: 8 additions & 0 deletions src/app/views/404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php include 'partials/header.php'; ?>
<div class="container">
<div class="error-page">
<h1>404</h1>
<p>Page not found</p>
</div>
</div>
<?php include 'partials/footer.php'; ?>
30 changes: 30 additions & 0 deletions src/app/views/account_view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php include 'partials/header.php'; ?>

<?php $account = $_SESSION['account']; ?>
<div>
<h1>Mon compte</h1>
<div class="account-details">
<div>
<label>Prénom</label>
<p><?= $account->first_name ?></p>
</div>
<div>
<label>Nom</label>
<p><?= $account->last_name ?></p>
</div>
<div>
<label>Adresse mail</label>
<p><?= $account->email ?></p>
</div>
<div>
<label>Téléphone</label>
<p><?= $account->phone ?></p>
</div>
<div>
<label>Date de création</label>
<p><?= $account->date_creation ?></p>
</div>
</div>
</div>

<?php include 'partials/footer.php'; ?>
11 changes: 11 additions & 0 deletions src/app/views/home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php include 'partials/header.php'; ?>

<h1>Bienvenue a EFES KEBAB </h1>

<div class="container">Home page</div>
<p>Découvrez nos plats savoureux !</p>


<p>mettre horaire, photos, etc... </p>

<?php include 'partials/footer.php'; ?>
2 changes: 2 additions & 0 deletions src/app/views/partials/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
</body>
</html>
9 changes: 9 additions & 0 deletions src/app/views/partials/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo isset($title) ? $title : "EFES KEBAB"; ?></title></head>
<body>
<?php include 'navbar.php';
// [FIXME] Or might be also 'nav.php'
?>
14 changes: 14 additions & 0 deletions src/app/views/partials/nav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require __DIR__ . '/../../models/account.php';

session_start();
if (!isset($_SESSION['account'])) {
$account = null;
} else {
$account = $_SESSION['account'];
}
?>
<nav>
<!--TODO : this file may be deleted since it has been implemented in navbar.php-->
</nav>
25 changes: 25 additions & 0 deletions src/app/views/partials/navbar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
require __DIR__ . '/../../models/account.php';

if (!isset($_SESSION['account'])) {
$account = null;
} else {
$account = $_SESSION['account'];
}
?>

<nav class="navbar">
<div class="container">
<ul class="pages-list">
<li><a href="/">Home</a></li>
<?php if ($account) { ?>
<li><a href="#">Commander</a></li>
<li><a href="/account">Mon compte</a></li>
<li><a href="/basket">Mon panier</a></li>
<?php } else { ?>
<li><a href="/sign-in">Sign-in</a></li>
<li><a href="/sign-up">Sign-up</a></li>
<?php } ?>
</ul>
</div>
</nav>
16 changes: 16 additions & 0 deletions src/app/views/sign-in.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php include 'partials/header.php'; ?>
<div>
<h1>Sign in</h1>
<form action="../controllers/sign-in.php" method="post">
<div>
<label for="email">Email address</label>
<input type="email" id="email" name="email" placeholder="you@example.com" required>
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>
</div>
<button type="submit">Sign in</button>
</form>
</div>
<?php include 'partials/footer.php'; ?>
35 changes: 35 additions & 0 deletions src/app/views/sign-up.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php include 'partials/header.php'; ?>
<div>
<h1>Sign up</h1>
<form action="../controllers/sign-up.php" method="post">
<div>
<div>
<label for="first_name">First name</label>
<input type="text" id="first_name" name="first_name" placeholder="John" required>
</div>
<div>
<label for="last_name">Last name</label>
<input type="text" id="last_name" name="last_name" placeholder="Doe" required>
</div>
</div>
<div>
<!-- TODO: Add country prefix ? auto spacing ? -->
<label for="phone">Phone number</label>
<input type="number" id="phone" name="phone" required>
</div>
<div>
<label for="email">Email address</label>
<input type="email" id="email" name="email" placeholder="you@example.com" required>
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Create a password" required>
</div>
<div>
<label for="confirm_password">Confirm password</label>
<input type="password" id="confirm_password" name="confirm_password" placeholder="Repeat your password" required>
</div>
<button type="submit">Create account</button>
</form>
</div>
<?php include 'partials/footer.php'; ?>
7 changes: 4 additions & 3 deletions src/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
return [
'GET' => [
'/' => ['TestController', 'test'],
'/test' => ['TestController', 'test'],
'/test2' => ['TestController', 'test2'],
'/' => ['HomeController', 'home'],
'/sign-in' => ['HomeController', 'viewSignIn'],
'/sign-up' => ['HomeController', 'viewSignUp'],
'/account' => ['HomeController', 'viewAccount'],
],
'POST' => [

Expand Down