Part on authorisation finished
This commit is contained in:
parent
0c5e0088f7
commit
44a6d295d8
2 changed files with 26 additions and 15 deletions
|
|
@ -6,6 +6,16 @@
|
|||
|
||||
$heading = "Note";
|
||||
|
||||
$note = $db->query('select * from notes where id = :id', ['id' => $_GET['id']] )->fetch();
|
||||
$note = $db->query('select * from notes where id = :id', [
|
||||
'id' => $_GET['id']
|
||||
])->fetch();
|
||||
|
||||
if (!$note) {
|
||||
abort();
|
||||
}
|
||||
$currentUserId = 1;
|
||||
if ($note['user_id'] != $currentUserId) {
|
||||
abort(Response::FORBIDDEN);
|
||||
}
|
||||
//dd($notes);
|
||||
require "views/note.view.php";
|
||||
15
index.php
15
index.php
|
|
@ -2,14 +2,15 @@
|
|||
require 'functions.php';
|
||||
require 'Database.php';
|
||||
require 'router.php';
|
||||
$username = 'appUser';
|
||||
$password = 'password';
|
||||
$config = require('config.php');
|
||||
$db = new Database($config['database'], $username, $password);
|
||||
$id = $_GET['id'];
|
||||
require 'Response.php';
|
||||
//$username = 'appUser';
|
||||
//$password = 'password';
|
||||
//$config = require('config.php');
|
||||
//$db = new Database($config['database'], $username, $password);
|
||||
//$id = $_GET['id'];
|
||||
// Variante 1
|
||||
$query = "SELECT * FROM posts WHERE id = ?";
|
||||
$posts = $db->query($query, [$id])->fetchAll(PDO::FETCH_ASSOC);
|
||||
//$query = "SELECT * FROM posts WHERE id = ?";
|
||||
//$posts = $db->query($query, [$id])->fetchAll(PDO::FETCH_ASSOC);
|
||||
// Variante 2
|
||||
//$query = "SELECT * FROM posts WHERE id = :id";
|
||||
//$posts = $db->query($query, [':id' => $id])->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue