-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_comment.php
70 lines (60 loc) · 2.01 KB
/
update_comment.php
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
61
62
63
64
65
66
67
68
69
70
<?php
session_start();
require_once('conn.php');
require_once('utils.php');
$id = $_GET['id'];
$username = NULL;
$user = NULL;
if (!empty($_SESSION['username'])) {
$username = $_SESSION['username'];
$user = getUserFromUsername($username);
}
$stmt = $conn->prepare(
"SELECT * FROM peipei_comments WHERE id=?"
);
$stmt->bind_param('i', $id);
$result = $stmt->execute();
if (!$result) {
die('Error' . $conn->error);
}
$result = $stmt->get_result();
$row = $result->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PHP message board</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="warning">
<strong>This is a website for practicing php. Please do not leave your normal password.</strong>
</header>
<main class="board">
<section class="form_container">
<div class="form_head">
<h1>Edit message</h1>
<?php
if (!empty($_GET['errCode'])) {
$code = $_GET['errCode'];
$msg = 'Erro';
if ($code === '1') {
$msg = 'Information is not completed.';
}
echo '<h2>Error message:' . $msg . '</h2>';
}
?>
</div>
<div class="form_body">
<form method="POST" action="handle_update_comment.php">
<textarea class="form_body_content" rows="5" name="content"><?php
echo escape($row['content']); ?></textarea>
<input type="hidden" name="id" value="<?php echo $row['id']; ?>"/>
<input class="form_body_btn"type="submit" value="Submit" />
</form>
</div>
</section>
</main>
</body>
</html>