Added: MVC structure, Router, Views and Controllers for home page and login/signup

This commit is contained in:
2024-12-25 23:02:09 +01:00
parent 7b4b349816
commit 3144078860
17 changed files with 167 additions and 0 deletions

View File

@ -0,0 +1,19 @@
<?php
class AuthController {
public function signin() {
$view = new View();
$data = [
'title' => 'Log In'
];
$view->render('auth/signin', $data);
}
public function signup() {
$view = new View();
$data = [
'title' => 'Register'
];
$view->render('auth/signup', $data);
}
}

View File

@ -0,0 +1,22 @@
<?php
class HomeController {
//private function render($view) {
// ob_start();
// require_once views . $view;
// $content = ob_get_clean();
// require_once views . 'layouts/base.php';
//}
public function index() {
$view = new View();
$data = [
'title' => 'Home'
];
$view->render('home/index', $data);
//require_once views . 'home/index.php';
}
public function home() {
$this->index();
}
}

View File

@ -0,0 +1,9 @@
<section class="signin">
<form>
<label for="username">Username</label>
<input type="text" name="username" id="username">
<label for="password">Password</label>
<input type="password" name="password" id="password">
<input type="submit" value="Sign In" id="submit-signin">
</form>
</section>

11
app/views/auth/signup.php Normal file
View File

@ -0,0 +1,11 @@
<section class="signup">
<form>
<label for="username">Username</label>
<input type="text" name="username" id="username">
<label for="password">Password</label>
<input type="password" name="password" id="password">
<label for="password-2">Password again</label>
<input type="password" name="password-2" id="password-2">
<input type="submit" value="Sign Up" id="submit-signup">
</form>
</section>

View File

13
app/views/errors/404.php Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Habit Tracker | Error 494</title>
</head>
<body>
<h1>Error 404 - Page not found</h1>
<a href="/">Go back home</a>
</body>
</html>

View File

View File

4
app/views/home/index.php Normal file
View File

@ -0,0 +1,4 @@
<div>
<h1>Welcome to Habit Tracker!</h1>
<p>Track your habits and achieve your goals.</p>
</div>

View File

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Habit Tracker | <?= $data['title'] ?></title>
</head>
<body>
<header>
<a href="/auth/signin">Log In</a>
<a href="/auth/signup">Sign Up</a>
</header>
<section class="content">
<?= $content ?>
</section>
</body>
</html>

View File

View File

@ -0,0 +1,4 @@
<header>
<a href="/signin">Log In</a>
<a href="/signup">Sign Up</a>
</header>