PHP5 SimpleXML with forms (CMS)

PHP5 SimpleXML with forms (CMS)

am 23.04.2008 11:10:30 von Pablo

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.

Re: PHP5 SimpleXML with forms (CMS)

am 23.04.2008 12:39:48 von Jerry Stuckle

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.
jstucklex@attglobal.net
==================

Re: PHP5 SimpleXML with forms (CMS)

am 23.04.2008 13:32:56 von Pablo

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=B4s 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=3D, &image=3D, 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.

Re: PHP5 SimpleXML with forms (CMS)

am 23.04.2008 19:12:28 von Jerry Stuckle

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.
jstucklex@attglobal.net
==================

Re: PHP5 SimpleXML with forms (CMS)

am 24.04.2008 12:29:13 von Pablo

> 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: text to update from
the form
. The only thing I need is to update the
data of the node from the form. That=B4s all. Can you give
me an example of the code that works?

Thank you so much again,

Pablo.

Re: PHP5 SimpleXML with forms (CMS)

am 24.04.2008 13:44:22 von Jerry Stuckle

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: text to update from
> the form
. The only thing I need is to update the
> data of the node from 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.
jstucklex@attglobal.net
==================