-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
19 lines (19 loc) · 851 Bytes
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
if($_POST['name']==NULL||$_POST['message']==NULL)
{
echo "<script>alert('留言錯誤!請輸入留言人和留言內容!');location.href='editMessage.php?id=".$_GET['id']."'</script>";
}
else{
$xml = file_get_contents("board.xml");
$dom = DOMDocument::loadXML($xml);
$comment = $dom->getElementsByTagName('comment')->item($_GET['id']);
$name = $comment->getElementsByTagName('name')->item(0);
$comment->replaceChild(new DOMElement("name", $_POST['name']),$name);
$message = $comment->getElementsByTagName('message')->item(0);
$comment->replaceChild(new DOMElement("message", $_POST['message']),$message);
$dom->formatOutput = true;
$dom->saveXML();
$dom->save("board.xml");
echo "<script>location.href='index.php'</script>";
}
?>