|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all experts,
I want to make a multiple selection form that allow user to upload picture, enter picture name,caption and url. I know how to make the form and i'm working on the uploading part. Just i need to know its how to generate all the data into xml once the user click submit button. Thanks for everyone help. Here is the xml output i need to generate:Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <images> <pic> <image>http://www.test.com/img/25.jpg</image> <caption>webcaption> <url>http://www.test.com</url> </pic> <pic> <image>http://www.test.com/img/26.jpg</image> <caption>web_pagecaption> <url>http://www.test.com/wp</url> </pic> <pic> ..... </pic> </images> |
|
#2
|
|||
|
|||
|
Here you can go.
$_POST['image'], $_POST['caption'], $_POST['url'] are the posted HTML elements names. $image = $_POST['image']; $caption = $_POST['caption']; $image = $_POST['url']; After gathering all data from the form then, I created a variable to hold all the data entered by user in string format. $xml_dec = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; $rootELementStart = "<employee>"; $rootElementEnd = "</employee>"; $xml_doc= $xml_dec; $xml_doc .= $rootELementStart; $xml_doc .= "<image>"; $xml_doc .= $image; $xml_doc .= "</image>"; $xml_doc .= "<caption>"; $xml_doc .= $caption; $xml_doc .= "</caption>"; $xml_doc .= "<url>"; $xml_doc .= $url; $xml_doc .= "</url>"; $xml_doc .= $rootElementEnd; $fp = fopen("example.xml",'w'); $write = fwrite($fp,$xml_doc); fopen function opens file or URL. I assume that xml_file directory is there so I have checked for error during fopen function call. I have used fwrite($fp,$xml_doc); to store the xml string into a file. _________________________ RichAppsConsulting |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > PHP-General - Quick Question: Saving form data into .xml with PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|