-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
32 lines (22 loc) · 877 Bytes
/
update.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
<?php
require_once('db.class.php' );
$db = new DB('localhost', 'elclubexpress', 'dir7xin4', 'elclubepxress');
if (isset($_POST['comment'])) {
$comment = htmlentities($_POST['comment'], ENT_QUOTES, 'UTF-8');
$comment = stripslashes($comment);
$comment = nl2br($comment);
$db->execute("INSERT INTO commentstable SET comment = '$comment'");
$query = $db->query("SELECT id, comment FROM commentstable ORDER BY id DESC");
$row = $db->fetchObject($query);
?>
<li class="k-<?php echo $row->id; ?>">
<span class="comment"><?php echo $row->comment; ?></span>
<span class="del"><a href="#" title="Delete" id="<?php echo $row->id; ?>" class="delete">X</a></span>
</li>
<?php
}
if ($_POST['id']) {
$id = (int)($_POST['id']);
$db->execute("DELETE FROM commentstable WHERE id = $id LIMIT 1");
}
?>