Use PHP to pass the contents of a form into a new xml file with download prompt -
i'm new programming guidance great, i'm trying achieve follows:
- have simple html form fields (text areas , text fields)
- when submiting form open dialog choose location save file, file name should default set forms first text area.
- save file , add contents of form specific xml tags
for instace
i want capture content of text area name "articlebody" , have saved on file under tag
can point me right tutorials? or upload snippet? time.
going off top of head:
form:
<form action="" method="post"> 1. filename: <input type="text" name="filename" /><br /> 2. field 1: <input type="text" name="field1" /><br /> 3. field 2: <input type="text" name="field2" /><br /> </form> script:
$filename = $_post['filename']; $field1 = $_post['field1']; $field2 = $_post['field2']; $field1 = htmlspecialchars($field1); $field2 = htmlspecialchars($field2); $xml = <<<eol <rootnode> <field>$field1</field> <field>$field2</field> </rootnode> eol; header('content-type: text/xml'); header('content-length: ' . strlen($xml)); header("content-disposition: attachment;filename=$filename"); echo $xml;
Comments
Post a Comment