Part on Forms finished
This commit is contained in:
parent
672ef6a949
commit
c0aeac2632
6 changed files with 54 additions and 12 deletions
6
controllers/note-create.php
Normal file
6
controllers/note-create.php
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
$heading = 'Create Note';
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
||||||
|
dd($_POST);
|
||||||
|
}
|
||||||
|
require 'views/note-create.view.php';
|
||||||
12
router.php
12
router.php
|
|
@ -1,16 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$uri = parse_url($_SERVER['REQUEST_URI'])['path'];
|
$uri = parse_url($_SERVER['REQUEST_URI'])['path'];
|
||||||
|
$routes = require ('routes.php');
|
||||||
$routes = [
|
|
||||||
'/' => 'controllers/index.php',
|
|
||||||
'/about' => 'controllers/about.php',
|
|
||||||
'/contact' => 'controllers/contact.php',
|
|
||||||
'/learn' => 'controllers/learn.php',
|
|
||||||
'/mathe' => 'controllers/mathe.php',
|
|
||||||
'/note' => 'controllers/note.php',
|
|
||||||
'/notes' => 'controllers/notes.php',
|
|
||||||
'/addition' => 'controllers/addition.php'
|
|
||||||
];
|
|
||||||
|
|
||||||
function routeToController($uri, $routes) {
|
function routeToController($uri, $routes) {
|
||||||
if (array_key_exists($uri, $routes)) {
|
if (array_key_exists($uri, $routes)) {
|
||||||
|
|
|
||||||
12
routes.php
Normal file
12
routes.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
return[
|
||||||
|
'/' => 'controllers/index.php',
|
||||||
|
'/about' => 'controllers/about.php',
|
||||||
|
'/contact' => 'controllers/contact.php',
|
||||||
|
'/learn' => 'controllers/learn.php',
|
||||||
|
'/mathe' => 'controllers/mathe.php',
|
||||||
|
'/note' => 'controllers/note.php',
|
||||||
|
'/notes' => 'controllers/notes.php',
|
||||||
|
'/addition' => 'controllers/addition.php',
|
||||||
|
'/notes/create' => 'controllers/note-create.php'
|
||||||
|
];
|
||||||
29
views/note-create.view.php
Normal file
29
views/note-create.view.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php require('partials/head.php') ?>
|
||||||
|
<?php require('partials/nav.php') ?>
|
||||||
|
<?php require('partials/banner.php') ?>
|
||||||
|
<main>
|
||||||
|
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
|
||||||
|
<div>
|
||||||
|
<div class="md:grid md:grid-cols-3 md:gap-6">
|
||||||
|
<div class="mt-5 md:col-span-2 md:mt-0">
|
||||||
|
<form method="POST">
|
||||||
|
<div class="shadow sm:overflow-hidden sm:rounded-md">
|
||||||
|
<div class="space-y-6 bg-white px-4 py-5 sm:p-6">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="body" class="block text-sm font-medium text-gray-700">Body</label>
|
||||||
|
<div class="mt-1">
|
||||||
|
<textarea id="body" name="body" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-gray-50 px-4 py-3 text-right sm:px-6">
|
||||||
|
<button type="submit" class="inline-flex justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<?php require('partials/footer.php') ?>
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<?php require ('partials/banner.php') ?>
|
<?php require ('partials/banner.php') ?>
|
||||||
<main>
|
<main>
|
||||||
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
|
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
|
||||||
|
<ul>
|
||||||
<?php foreach ($notes as $note) : ?>
|
<?php foreach ($notes as $note) : ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="/note?id=<?= $note['id'] ?>" class="text-blue-500 hover:underline">
|
<a href="/note?id=<?= $note['id'] ?>" class="text-blue-500 hover:underline">
|
||||||
|
|
@ -10,6 +11,10 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<p class="mt-6">
|
||||||
|
<a href="/notes/create" class="text-blue-500 hover:underline">Create Note</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<?php require ('partials/footer.php') ?>
|
<?php require ('partials/footer.php') ?>
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com?plugins=forms"></script>
|
||||||
<title>Demo</title>
|
<title>Demo</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="h-full">
|
<body class="h-full">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue