473,802 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

want to export form input to xml using php

89 New Member
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_registe r("LoggedIn") ;
session_registe r("SavedSearchT ype");
session_registe r("SalesRepID") ;
session_registe r("SavedCustID" );
session_registe r("SavedFromDat e");
session_registe r("SavedToDate" );
session_registe r("WebCompanyNa me");
session_registe r("CompanyName" );
session_registe r('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($qu ery,$conn);
if (mssql_num_rows ($result) > 0) {
$userinfo = mssql_fetch_arr ay($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="retur n checkFields3(); ">

<input type="hidden" name="CompanyNa me" 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="cuoutthic kness" type="radio" value="35 µ" />
<input name="cuoutthic kness" 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_Inf o>
<Company_name>x xxxx</Company_name>
<Address>xxxx x</Address>
<City>xxxxx</City>
<Zip>xxxxx</Zip>
<Country>xxxx x</Country>
<CustID>xxxxx </CustID>
</Customer_Info>
- <CAD_Data>
<part_name>xxxx xxx</part_name>
<layers>xxxxxxx </layers>
<quantity>xxxxx xx</quantity>
<pcbwidth>xxxxx xx</pcbwidth>
<pcbheight>xxxx xxx</pcbheight>
<thickness>xxxx xxx</thickness>
<copperthicknes s>xxxxxxx</copperthickness >
<delivery>xxxxx xx</delivery>
</CAD_Data>[/HTML]

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

Thanks in advance!
Aug 26 '08 #1
1 3106
Dormilich
8,658 Recognized Expert Moderator Expert
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
29532
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" keyword? if it is, i know the history that is without "export" keyword of C++ compilers with five years (sorry about my poor english :-) ), in five years still have no some idea to implement it ? my project and many C++ programmers need this important...
205
10726
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
7496
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, defining more than 250 base names for the lobs leads to an error message something like "DB2 encountered an unexpected error when sending the query to the backend process" (I don't have the exact message at hand). It doesn't matter how short the base...
16
11883
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. I can do this individually for each graph but this does not help me as I need both on the same JPEG. I thought I would try an export the form that contains both but I am having trouble. (My VBA is self taught and a little knowledge is...
7
14380
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 display the graph but it is not possible to send query parameters to an OLE graph on a report (or programatically change any properties of an OLE Graph). However with a Form you do have the ability to change the RowSource of
10
14740
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 vba is a little confusing for me since i have never used it plus i have lost touch with vb coding since last 8 monhts. anywayz, my problem is i'm trying to export a table that's modified by me which is taken from a file at a prompt, now i have to...
2
7981
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 data (records) from dataset to may XML file. For example:
3
2606
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
1
1245
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 suggest me the best way to implement. I would appreciate your reply. Thank you, GSR
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.