Edit XML with Form
Posted: Tue Jun 15, 2010 12:42 pm
I am designing a portfolio website for a photographer and I wanted to create an admin system for him to edit the flash website.
I am loading a XML file into Flash. I want to be able to edit this xml data with PHP. I managed to figure out how to create a form that is generated from my xml file, but I need it to be functional.
Form: http://condiffphotography.com/xmledit.php
XML: http://condiffphotography.com/pricing.xml
Here is my code:
So basically I want to re-write the xml data based on the form values.
Is this difficult to do? Any help would be greatly appreciated.
Thanks.
I am loading a XML file into Flash. I want to be able to edit this xml data with PHP. I managed to figure out how to create a form that is generated from my xml file, but I need it to be functional.
Form: http://condiffphotography.com/xmledit.php
XML: http://condiffphotography.com/pricing.xml
Here is my code:
Code: Select all
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<h2>Edit Pricing</h2>
<form action="submit.php" method="post">
<div class="content">
<?php
$doc = new DOMDocument();
$doc->load( 'pricing.xml' );
$pricing = $doc->getElementsByTagName( "package" );
foreach( $pricing as $package )
{
$titles = $package->getElementsByTagName( "title" );
$title = $titles->item(0)->nodeValue;
$prices = $package->getElementsByTagName( "price" );
$price = $prices->item(0)->nodeValue;
$descriptions = $package->getElementsByTagName( "description" );
$description = $descriptions->item(0)->nodeValue;
echo "
<div id=\"package\" style=\"padding:20px\">
Package:<br />
Title: <input type=\"text\" value=\"$title\" name=\"title\" />
<br />
Price: <input type=\"text\" value=\"$price\" name=\"price\" />
<br />
Description: <br />
<textarea name=\"description\" />$description</textarea><br />
<input type=\"button\" name=\"remove\" value=\"Remove Package\"><br />
</div>
";
}
?>
</div>
<input type="button" name="add" value="Add Package"><br />
<input type="submit" name="mysubmit" value="Click">
</form>
<script>
function addPackage(){
$(".content").append('<div id="package" style="padding:20px">Package:<br />Title: <input type="text" value="" name="title" /><br />Price: <input type="text" value="" name="price" /><br />Description: <br /><textarea name="description" /></textarea><br /><input type="button" name="remove" value="Remove Package"><br /></div>');
}
</script>
</body>
</html>Is this difficult to do? Any help would be greatly appreciated.
Thanks.
