PHP5 SimpleXML with forms (CMS)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pablo

    PHP5 SimpleXML with forms (CMS)

    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.
  • Jerry Stuckle

    #2
    Re: PHP5 SimpleXML with forms (CMS)

    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@attgl obal.net
    =============== ===

    Comment

    • Pablo

      #3
      Re: PHP5 SimpleXML with forms (CMS)

      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.

      Comment

      • Jerry Stuckle

        #4
        Re: PHP5 SimpleXML with forms (CMS)

        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@attgl obal.net
        =============== ===

        Comment

        • Pablo

          #5
          Re: PHP5 SimpleXML with forms (CMS)

          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 "Descriptio n", and I have
          built the xml file manually: <page1><descrip tion>text to update from
          the form</description></page1>. The only thing I need is to update the
          data of the node <descriptionfro m the form. That´s all. Can you give
          me an example of the code that works?

          Thank you so much again,

          Pablo.

          Comment

          • Jerry Stuckle

            #6
            Re: PHP5 SimpleXML with forms (CMS)

            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 "Descriptio n", and I have
            built the xml file manually: <page1><descrip tion>text to update from
            the form</description></page1>. The only thing I need is to update the
            data of the node <descriptionfro m 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@attgl obal.net
            =============== ===

            Comment

            Working...