-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
60 lines (48 loc) · 1.15 KB
/
Copy pathedit.php
File metadata and controls
60 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require "db.php";
require "functions.php";
if(!isLoggedIn()) {
header("Location: login.php");
exit;
}
$id = $_GET["id"];
$book = getBook($sql, $id);
if(!isOwner($book)) {
header("Location: index.php");
exit;
}
if($_SERVER["REQUEST_METHOD"] == "POST") {
editBook($sql, $id, $_POST["title"], $_POST["author"]);
header("Location: index.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit Book</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<a href="index.php">Home</a>
<?php if(isLoggedIn()): ?>
<a href="add.php">Add Book</a>
<span>Logged in: <?= $_SESSION["name"] ?></span>
<a href="logout.php">Logout</a>
<?php else: ?>
<a href="register.php">Register</a>
<a href="login.php">Login</a>
<?php endif; ?>
</nav>
<div class="page">
<h1>Edit Book</h1>
<form method="post">
<input type="text" name="title" value="<?= $book["title"] ?>">
<input type="text" name="author" value="<?= $book["author"] ?>">
<button type="submit">Save</button>
</form>
</div>
</body>
</html>