Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit 70f4890

Browse files
Merge pull request #36 from TheRefraction/feature-home-404-account
Feature home 404 account
2 parents f1ceaad + 72e06e9 commit 70f4890

14 files changed

Lines changed: 242 additions & 3 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
class HomeController {
3+
public function home() {
4+
require_once __DIR__ . '/../views/home.php';
5+
}
6+
7+
public function viewSignIn() {
8+
require_once __DIR__ . '/../views/sign-in.php';
9+
}
10+
11+
public function viewSignUp() {
12+
require_once __DIR__ . '/../views/sign-up.php';
13+
}
14+
15+
public function viewAccount() {
16+
require_once __DIR__ . '/../views/account_view.php';
17+
}
18+
}

src/app/controllers/sign-in.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
require __DIR__ .'/../models/account.php';
4+
require __DIR__ .'/../../config/database.php';
5+
6+
$email = $_REQUEST["email"];
7+
$password = $_REQUEST["password"];
8+
9+
if(empty($_POST["email"])) {
10+
http_response_code(400);
11+
header('Location: /sign-in.php?error=1');
12+
}
13+
if(empty($_POST["password"])) {
14+
http_response_code(400);
15+
header('Location: /sign-in?error=1');
16+
}
17+
18+
$query = getConnection()->prepare('SELECT * FROM account WHERE email = :email');
19+
$query->execute(['email' => $email]);
20+
$account = $query->fetchObject(Account::class);
21+
22+
if(!$account) {
23+
header('Location: /sign-in?error=2');
24+
} else if(!password_verify($password, $account->password)) {
25+
header('Location: /sign-in?error=3');
26+
} else {
27+
session_start();
28+
$_SESSION['account'] = $account;
29+
//header('Location: /accueil');
30+
}

src/app/controllers/sign-up.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
require __DIR__ .'/../models/account.php';
4+
require __DIR__ .'/../../config/database.php';
5+
6+
$first_name = $_REQUEST["first_name"];
7+
$last_name = $_REQUEST["last_name"];
8+
$phone = $_REQUEST["phone"];
9+
$email = $_REQUEST["email"];
10+
$password = $_REQUEST["password"];
11+
12+
if (
13+
empty($_POST["first_name"]) ||
14+
empty($_POST["last_name"]) ||
15+
empty($_POST["phone"]) ||
16+
empty($_POST["email"]) ||
17+
empty($_POST["password"])) {
18+
http_response_code(400);
19+
header('Location: /sign-up?error=1');
20+
}
21+
22+
$query = getConnection()->prepare('INSERT INTO account (first_name, last_name, phone, email, password, date_creation, role) VALUES (?, ?, ?, ?, ?, ?, ?)');
23+
$query->execute([$first_name, $last_name, $phone, $email, password_hash($password, PASSWORD_DEFAULT), date("Y-m-d"), 1]);
24+
25+
header('Location: /sign-in');

src/app/models/account.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
class Account
4+
{
5+
public $id;
6+
public $first_name;
7+
public $last_name;
8+
public $email;
9+
public $phone;
10+
public $password;
11+
public $date_creation;
12+
public $role_id;
13+
}
14+
15+
?>

src/app/views/404.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php include 'partials/header.php'; ?>
2+
<div class="container">
3+
<div class="error-page">
4+
<h1>404</h1>
5+
<p>Page not found</p>
6+
</div>
7+
</div>
8+
<?php include 'partials/footer.php'; ?>

src/app/views/account_view.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php include 'partials/header.php'; ?>
2+
3+
<?php $account = $_SESSION['account']; ?>
4+
<div>
5+
<h1>Mon compte</h1>
6+
<div class="account-details">
7+
<div>
8+
<label>Prénom</label>
9+
<p><?= $account->first_name ?></p>
10+
</div>
11+
<div>
12+
<label>Nom</label>
13+
<p><?= $account->last_name ?></p>
14+
</div>
15+
<div>
16+
<label>Adresse mail</label>
17+
<p><?= $account->email ?></p>
18+
</div>
19+
<div>
20+
<label>Téléphone</label>
21+
<p><?= $account->phone ?></p>
22+
</div>
23+
<div>
24+
<label>Date de création</label>
25+
<p><?= $account->date_creation ?></p>
26+
</div>
27+
</div>
28+
</div>
29+
30+
<?php include 'partials/footer.php'; ?>

src/app/views/home.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php include 'partials/header.php'; ?>
2+
3+
<h1>Bienvenue a EFES KEBAB </h1>
4+
5+
<div class="container">Home page</div>
6+
<p>Découvrez nos plats savoureux !</p>
7+
8+
9+
<p>mettre horaire, photos, etc... </p>
10+
11+
<?php include 'partials/footer.php'; ?>

src/app/views/partials/footer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
</body>
2+
</html>

src/app/views/partials/header.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html lang="fr">
2+
<head>
3+
<meta charset="utf-8" />
4+
<meta name="viewport" content="width=device-width, initial-scale=1">
5+
<title><?php echo isset($title) ? $title : "EFES KEBAB"; ?></title></head>
6+
<body>
7+
<?php include 'navbar.php';
8+
// [FIXME] Or might be also 'nav.php'
9+
?>

src/app/views/partials/nav.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
require __DIR__ . '/../../models/account.php';
4+
5+
session_start();
6+
if (!isset($_SESSION['account'])) {
7+
$account = null;
8+
} else {
9+
$account = $_SESSION['account'];
10+
}
11+
?>
12+
<nav>
13+
<!--TODO : this file may be deleted since it has been implemented in navbar.php-->
14+
</nav>

0 commit comments

Comments
 (0)