469,904 Members | 2,088 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

want to export form input to xml using php

Hello All

I'm quite new to xml vs. PHP, so i hope someone can help with an issue i have been struggeling with.

I have an html form, that when submitted, it should create an xml file, and save in a certain place on my server.

I know that this can be done using php, but i'm not sure how....?

Here is my php (which needs to be configured to output the xml file):


$conn = mssql_connect('host','username','password');

header("Cache-control: private");

if (!isset($_POST['CustID'])) {
$_POST['CustID'] = trim($_SESSION['SavedCustID']);

$_SESSION['SavedCustID'] = "All";
if (trim($_SESSION['ShowDetails']) == "Y") {
if (trim($_SESSION['WebUserType']) == "Rep") {
$_SESSION['SavedCustID'] = trim($_POST['CustID']);

if ($_SESSION['LoggedIn'] != true) {

$a = trim($_SESSION['UserID']);
$b = trim($_SESSION['Password']);
$query = "select * from USERINFO where (UserID = '" . $a . "' and Password = '" . $b . "')";
// print($query);
$result = mssql_query($query,$conn);
if (mssql_num_rows($result) > 0) {
$userinfo = mssql_fetch_array($result);
$CompanyName = $userinfo['CompanyName'];
$Addr1 = $userinfo['Addr1'];
$Addr2 = $userinfo['Addr2'];
$City = $userinfo['City'];
$State = $userinfo['State'];
$Zip = $userinfo['Zip'];
$Country = $userinfo['Country'];
$Phone = $userinfo['Phone'];
$CustID = trim($userinfo['CustID']);
} else {
$CompanyName = "";
$Addr1 = "";
$Addr2 = "";
$City = "";
$State = "";
$Zip = "";
$Country = "";
$Phone = "";
$CustID = "";

Here is my form:

[HTML]<form method="post" name="shopform" action="" onsubmit="return checkFields3();">

<input type="hidden" name="CompanyName" value="<?php echo $CompanyName; ?>" />
<input type="hidden" name="Addr1" value="<?php echo $Addr1; ?>" />
<input type="hidden" name="Addr2" value="<?php echo $Addr2; ?>" />
<input type="hidden" name="City" value="<?php echo $City; ?>" />
<input type="hidden" name="Zip" value="<?php echo $Zip; ?>" />
<input type="hidden" name="Country" value="<?php echo $Country; ?>" />
<input type="hidden" name="Phone" value="<?php echo $Phone; ?>" />
<input type="hidden" name="CustID" value="<?php echo $CustID; ?>" />

<input name="part_name" type="text" size="30" />
<input name="layers" value="2" type="radio" />
<input name="layers" value="4" type="radio" />
<input name="layers" value="6" type="radio" />
<input name="layers" value="8" type="radio" />
<input name="quantity" type="text" value="" size="5" />
<input name="pcbwidth" type="text" value="" size="5" />
<input name="pcbheight" type="text" value="" size="5" />
<input name="thickness" value="1.0" type="radio" />
<input name="thickness" value="1.6" type="radio" />
<input name="thickness" value="2.0" type="radio" />
<input name="cuoutthickness" type="radio" value="35 " />
<input name="cuoutthickness" type="radio" value="70 " />
<input name="surface" value="Silver" type="radio" />
<input name="surface" value="Leadfree HAL" type="radio" />
<input name="delivery" value="5 Working Days" type="radio" />
<input name="delivery" value="8 Working Days" type="radio" />
<input name="delivery" value="10 Working Days" type="radio" />
<input name="delivery" value="15 Working Days" type="radio" />

And the generated xmlfile should look something similar to this:

[HTML]<?xml version="1.0" encoding="UTF-8"?>
- <Customer_Info>
- <CAD_Data>

Any input/solution to this problem is more than welcome.

Thanks in advance!
Aug 26 '08 #1
1 2879
8,652 Expert Mod 8TB
If cou can make allowances to the structure of the xml file you can have a look at WDDX. this essentially serializes variables (e.g. arrays) into xml.
WDDX at Wikipedia
Aug 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by DarkSpy | last post: by
205 posts views Thread by Jeremy Siek | last post: by
1 post views Thread by Janne Ruuttunen | last post: by
16 posts views Thread by David Lauberts | last post: by
2 posts views Thread by Ghost | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.