This is for a CMS tool that does NOT use a DB. I decided to go with XML then. At first it was awesome. I am adding to the XML and it adds the content to the page with the corresponding pageid variable I have.
What if they need to add a page though? That's why I made this form.
I have this form
Code: Select all
<form method="post" action="newpage_submit.php">
<input type="text" value="Title" name="title"/><br />
<input type="text" value="Sub Header" name="subheader" /><br />
<input type="text" value="Content Here" name="content"/><br />
<input type="submit" name="save" />
</form>
Here is my barebones xml sheet.
Code: Select all
<website>
<webpage>
<title></title>
<subhead></subhead>
<content>
<p></p>
</content>
</webpage>
</website>
Code: Select all
<?php
$newpage_title = $_POST['title'];
$newpage_subheader = $_POST['subheader'];
$newpage_content = $_POST['content'];
$newpage_content = str_replace("\r", "<br />", $newpage_content);
$xw = new xmlWriter();
$xw->openMemory();
//$xw->setIndent(true);
$xw->startElement('webpage');
$xw->writeElement ('title', $newpage_title);
$xw->writeElement('subhead', $newpage_subheader);
$xw->writeElement('content', $newpage_content);
$xw->endElement(); // webpage
$xw = $xw->outputMemory(true);
$xw = str_replace(' ', '', $xw);
$xw = str_replace('<', '<', $xw);
$xw = str_replace('>', '>', $xw);
?>
Also, after it appends the XML sheet can it create a new new HTML document with ++pageid so that it makes a new page with a new page id and so it pulls the XML data in i without manually having to go and create a new HTML document copy and pasting the template and adding the the pageid up one?
If anyone can just get me how to append data that would be awesome!