473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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):

[PHP]<?php

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

session_start();
header("Cache-control: private");
session_register("LoggedIn");
session_register("SavedSearchType");
session_register("SalesRepID");
session_register("SavedCustID");
session_register("SavedFromDate");
session_register("SavedToDate");
session_register("WebCompanyName");
session_register("CompanyName");
session_register('WebUserType');

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) {
@include("./login.php");
return;
}

$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 = "";
}
?>
[/PHP]

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; ?>" />

<table>
<tr>
<td>
<input name="part_name" type="text" size="30" />
</td>
</tr>
<tr>
<td>
<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" />
</td>
</tr>
<tr>
<td>
<input name="quantity" type="text" value="" size="5" />
</td>
</tr>
<input name="pcbwidth" type="text" value="" size="5" />
<input name="pcbheight" type="text" value="" size="5" />
</td>
</tr>
<tr>
<td>
<input name="thickness" value="1.0" type="radio" />
<input name="thickness" value="1.6" type="radio" />
<input name="thickness" value="2.0" type="radio" />
</td>
</tr>
<tr>
<td>
<input name="cuoutthickness" type="radio" value="35 µ" />
<input name="cuoutthickness" type="radio" value="70 µ" />
</td>
</tr>
<tr>
<td>
<input name="surface" value="Silver" type="radio" />
<input name="surface" value="Leadfree HAL" type="radio" />
</td>
</tr>
<tr>
<td>
<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" />
</td>
</tr>
</table>
</form>[/HTML]

And the generated xmlfile should look something similar to this:

[HTML]<?xml version="1.0" encoding="UTF-8"?>
<Header>xxxxx</Header>
- <Customer_Info>
<Company_name>xxxxx</Company_name>
<Address>xxxxx</Address>
<City>xxxxx</City>
<Zip>xxxxx</Zip>
<Country>xxxxx</Country>
<CustID>xxxxx</CustID>
</Customer_Info>
- <CAD_Data>
<part_name>xxxxxxx</part_name>
<layers>xxxxxxx</layers>
<quantity>xxxxxxx</quantity>
<pcbwidth>xxxxxxx</pcbwidth>
<pcbheight>xxxxxxx</pcbheight>
<thickness>xxxxxxx</thickness>
<copperthickness>xxxxxxx</copperthickness>
<delivery>xxxxxxx</delivery>
</CAD_Data>[/HTML]

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

Thanks in advance!
Aug 26 '08 #1
1 3081
Dormilich
8,658 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

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

Similar topics

13
by: DarkSpy | last post by:
many c++ compilers including "gcc" have not implemented the "export" keyword, but the comeau compilers made it (just i knew). i want to know about: is it too difficult to implement "export"...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
1
by: Janne Ruuttunen | last post by:
Hello DB2 people, I'm having problems exporting >= 250000 lobs to IXF files with the LOBSINFILE option, using a legacy DB2 2.1 system on Win NT. If I don't specify a path for the lobs,...
16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
7
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to...
10
by: Neil | last post by:
Hi guyz, just trying out this google feature so if i post if in the wrong area i appologize. now to my question. BTW i'm new to access programming, i've done a little vb6.0 and vb.net but access...
2
by: Ghost | last post by:
Hello. What is the optimal way to manualy import/export data from/to XML file to/form my DataSet? What I wnat: 1. To add some data (records) from XML file to may dataset. 2.. To add some...
3
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
1
by: GSR | last post by:
Can you suggest me, How to export data from database and user input to cusomized xml format using webservice. xml format may change some times, so should be scalable to export to that format. Please...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.