By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

PHP5 SimpleXML with forms (CMS)

P: n/a
Hello,

Does anybody know any tutorial about using PHP5 SimpleXML with forms?
I have found some SimpleXML examples, but only modifying node
attributes from the php code directly.

I would like to make a simple CMS based on a page with a form
containing 2 fields (text description and picture uploader), wich data
(the text and the path to the picture file in the server) is stored in
a xml file.

Thanks in advance,

Pablo.
Jun 2 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Pablo wrote:
Hello,

Does anybody know any tutorial about using PHP5 SimpleXML with forms?
I have found some SimpleXML examples, but only modifying node
attributes from the php code directly.

I would like to make a simple CMS based on a page with a form
containing 2 fields (text description and picture uploader), wich data
(the text and the path to the picture file in the server) is stored in
a xml file.

Thanks in advance,

Pablo.
I think XML is the wrong tool for this. Use a database - much easier
(and faster).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #2

P: n/a
Thanks Jerry, but this CMS is just for updating the data shown in a
Flash site, not for a list of records in a relational DB or something
like that.

Thatīs why i prefer to post the variables in a xml file -or just a txt
file-, from the form to show them from the dynamic fields in the swf.
Can it be possible?

For now, I have a txt file with the variables &text=, &image=, etc.
where the swf get the data to show. If I use xml, Flash can parse the
file to show directly the attributes.

Thank you again,

Pablo.
Jun 2 '08 #3

P: n/a
Pablo wrote:
Thanks Jerry, but this CMS is just for updating the data shown in a
Flash site, not for a list of records in a relational DB or something
like that.
OK, but I still think it's a better way to go, especially if you're
updating the data fairly often. Remember to flock() the file before
every access (write OR read) to ensure you don't have two people
updating at the same time and no one gets a partially-written file.
Thatīs why i prefer to post the variables in a xml file -or just a txt
file-, from the form to show them from the dynamic fields in the swf.
Can it be possible?

For now, I have a txt file with the variables &text=, &image=, etc.
where the swf get the data to show. If I use xml, Flash can parse the
file to show directly the attributes.

Thank you again,

Pablo.
OK, you can do it, but I'm not sure this is the right way to go.

You can build your XML document with SimpleXML using addChild() and
addAttribute(), then use asXML() to write it to your file. Not too
hard, if the XML is simple.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #4

P: n/a
You can build your XML document with SimpleXML using addChild() and
addAttribute(), then use asXML() to write it to your file. Not too
hard, if the XML is simple.
Hi Jerry,

This is just the key of my question. How can I make the form and
simpleXML work together to write the data posted from the form in the
attributes of the xml file?

I.E. I have a form with just a text field "Description", and I have
built the xml file manually: <page1><description>text to update from
the form</description></page1>. The only thing I need is to update the
data of the node <descriptionfrom the form. Thatīs all. Can you give
me an example of the code that works?

Thank you so much again,

Pablo.
Jun 2 '08 #5

P: n/a
Pablo wrote:
>You can build your XML document with SimpleXML using addChild() and
addAttribute(), then use asXML() to write it to your file. Not too
hard, if the XML is simple.

Hi Jerry,

This is just the key of my question. How can I make the form and
simpleXML work together to write the data posted from the form in the
attributes of the xml file?

I.E. I have a form with just a text field "Description", and I have
built the xml file manually: <page1><description>text to update from
the form</description></page1>. The only thing I need is to update the
data of the node <descriptionfrom the form. Thatīs all. Can you give
me an example of the code that works?

Thank you so much again,

Pablo.
You just need to load the file into the class, then set the element, i.e.

$xml->page1->description = (new description here)

Finally, write the entire object back to the file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.