-
Notifications
You must be signed in to change notification settings - Fork 0
/
editComment.php
48 lines (48 loc) · 1.22 KB
/
editComment.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
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
<title>Re-edit Comment</title>
<style type="text/css">
body{
width: 760px; /* how wide to make your web page */
background-color: teal; /* what color to make the background */
margin: 0 auto;
padding: 0;
font:12px/16px Verdana, sans-serif; /* default font */
}
div#main{
background-color: #FFF;
margin: 0;
padding: 10px;
}
</style>
</head>
<body><div id="main">
<?php
require 'database.php';
session_start();
$newsId = $_SESSION['newsId'];
$commentId = $_SESSION['commentId'];
$comment = $_POST['comment'];
if ((!isset($comment) || trim($comment)==='')) {
echo "<p>Comment cannot be empty or only whitespace.</p>";
} else {
$stmt = $mysqli->prepare("update comments set content=? where id=?");
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
exit;
}
$stmt->bind_param('ss', $comment, $commentId);
$stmt->execute();
$stmt->close();
echo "<p>Your comment was edited successfully!</p>";
}
?>
<p>
<form name="backToNews" action="readNews.php" method="GET">
<input type="submit" value="Back to News" />
<input type="hidden" name="newsId" value="<?php echo $newsId;?>"/>
</form>
</p>
</div></body>
</html>