473,405 Members | 2,349 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,405 software developers and data experts.

PHP XML XSL HTML Form

Hello all,

I am working on a generic (php) script to produce (X)HTML Forms through XML
and XSL based on field-definitions stored in a database.

The basic way i did HTML-forms in PHP was like this:
http://212.204.203.71/test/simpleform/simpleform.php

source: http://212.204.203.71/test/syntax/simpleform.php

This basic form is validated when it is submitted to itself... if validation
fails then an error message is created and displayed on the page...otherwise
validation is ok and we can do some inserting in the database and/or
redirect to another page. Remark: the fields that are filled will be
automaically filled in if the page is submitted to itself (that will be my
problem in the XML/XSL version of this script).

Now we go over to the XML/XSL version of the script above: I therefore
created an XML file (holding the field definitions) see:
http://212.204.203.71/test/xmlform/form.xml

And further i created an XSL file to transform the XML file into a HTML
form. see: http://212.204.203.71/test/xmlform/form.xsl

Then i used a file form.php to put the XML and XSL together using some PHP
xslt functions: http://212.204.203.71/test/xmlform/form.php

source: http://212.204.203.71/test/syntax/form.php

This all works fine but now the problem. I am looking for a concept of how
to get the formfields filled in again after submitting the form because in
XSL this is not as easy as with my basic form. I tried to send firstname and
lastname as parameters in the function call and to put them as parameters in
the xsl file but that does not work and it is not ok at all because my
intention was to build a generic script....

Hope you see my problem as it is hard to explain.

Regards,

Jochem (jo***********@REMOVETHISANTISPAMquicknet.nl)

Jul 17 '05 #1
5 2844
Take a look at my sample application which is PHP+MySQL+XML+XSL and which
does what you describe. Run it online, or download the source code to see
how it works.

HTH.

--
Tony Marston

http://www.tonymarston.net

"Marcel" <so***************@nospam.com> wrote in message
news:4c***************************@news.multikabel .nl...
Hello all,

I am working on a generic (php) script to produce (X)HTML Forms through
XML
and XSL based on field-definitions stored in a database.

The basic way i did HTML-forms in PHP was like this:
http://212.204.203.71/test/simpleform/simpleform.php

source: http://212.204.203.71/test/syntax/simpleform.php

This basic form is validated when it is submitted to itself... if
validation
fails then an error message is created and displayed on the
page...otherwise
validation is ok and we can do some inserting in the database and/or
redirect to another page. Remark: the fields that are filled will be
automaically filled in if the page is submitted to itself (that will be my
problem in the XML/XSL version of this script).

Now we go over to the XML/XSL version of the script above: I therefore
created an XML file (holding the field definitions) see:
http://212.204.203.71/test/xmlform/form.xml

And further i created an XSL file to transform the XML file into a HTML
form. see: http://212.204.203.71/test/xmlform/form.xsl

Then i used a file form.php to put the XML and XSL together using some PHP
xslt functions: http://212.204.203.71/test/xmlform/form.php

source: http://212.204.203.71/test/syntax/form.php

This all works fine but now the problem. I am looking for a concept of how
to get the formfields filled in again after submitting the form because in
XSL this is not as easy as with my basic form. I tried to send firstname
and
lastname as parameters in the function call and to put them as parameters
in
the xsl file but that does not work and it is not ok at all because my
intention was to build a generic script....

Hope you see my problem as it is hard to explain.

Regards,

Jochem (jo***********@REMOVETHISANTISPAMquicknet.nl)

Jul 17 '05 #2
Marcel wrote:

This all works fine but now the problem. I am looking for a concept of how
to get the formfields filled in again after submitting the form


At the top of the form try something like this:

$clean = array();
foreach ($_POST as $name=>$value) {
$clean[$name] = YourSanitizeFunction($value);
}

If javascript is acceptable to you , just toss this at the bottom (usual
disclaimers about top-of-my-head, no error checking blah blah):

echo "<script>\n";
foreach ($clean as $name=$value) {
echo "document.getElementsByName($name)[0].value='$value'\n";
}
echo "</script>\n";

This will work in IE, Mozilla, and Opera. In production you would on
general principles replace the verbose "document.getElements..." construct
with a function call to some function that does the same thing.

Now, if Javascript is not acceptable, then somebody more knowledgeable than
I will have to tell you how to do the transform. I won't touch for
something like this because it seems like a lot of extra steps. I mean, if
you have to generate the transformation out of a dictionary, why not
generate the HTML and save some steps and retain more control? It's so
much easier to do this:

foreach ($dictionary_cols as $colname=>$colinfo) {
$name = logic goes here...
$value = $colinfo["value"];
$disabled = logic goes here...
echo "<input name=\"$name\" id=\"$name\" $disabled $value=\"$value\">....
}

--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Jul 17 '05 #3

"Tony Marston" <to**@NOSPAM.demon.co.uk> schreef in bericht
news:d0*******************@news.demon.co.uk...
Take a look at my sample application which is PHP+MySQL+XML+XSL and which
does what you describe. Run it online, or download the source code to see
how it works.

HTH.

--


Hi Tony,

Thanks for your answer! I am impressed by the number of examples on your
site. Can you please tell me which example i should use e.g which example
covers my posting?

Thanks and regards,

Marcel
Jul 17 '05 #4
Try any of the input forms as these reshow any user-entered data as well as
any error messages.

--
Tony Marston

http://www.tonymarston.net

"Barbara" <ge******@quicknet.nl> wrote in message
news:72**************************@news.multikabel. nl...

"Tony Marston" <to**@NOSPAM.demon.co.uk> schreef in bericht
news:d0*******************@news.demon.co.uk...
Take a look at my sample application which is PHP+MySQL+XML+XSL and which
does what you describe. Run it online, or download the source code to see
how it works.

HTH.

--


Hi Tony,

Thanks for your answer! I am impressed by the number of examples on your
site. Can you please tell me which example i should use e.g which example
covers my posting?

Thanks and regards,

Marcel

Jul 17 '05 #5
Ok i will, thanks a lot Tony!!!
"Tony Marston" <to**@NOSPAM.demon.co.uk> schreef in bericht
news:d0*******************@news.demon.co.uk...
Try any of the input forms as these reshow any user-entered data as well
as any error messages.

--
Tony Marston

http://www.tonymarston.net

"Barbara" <ge******@quicknet.nl> wrote in message
news:72**************************@news.multikabel. nl...

"Tony Marston" <to**@NOSPAM.demon.co.uk> schreef in bericht
news:d0*******************@news.demon.co.uk...
Take a look at my sample application which is PHP+MySQL+XML+XSL and
which
does what you describe. Run it online, or download the source code to
see
how it works.

HTH.

--


Hi Tony,

Thanks for your answer! I am impressed by the number of examples on your
site. Can you please tell me which example i should use e.g which example
covers my posting?

Thanks and regards,

Marcel


Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hansan | last post by:
Hi all, I hope you have time to help me out a little. My problem is that I want to combine some python code I have made with some html templates, I found a tutorial at dev shed:...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
4
by: Sathyaish | last post by:
I am no JavaScript progammer, and unfortunately am having to babysit an old code base that has a lot of JavaScript in it. I have two questions: (1) Can two HTML controls have the same name? It...
7
by: thersitz | last post by:
I can't seem to get my html form to submit properly from within a web form. Here's my form tag syntax and some delivery hidden fields. <form id="myForm"...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: Arpit Nagar | last post by:
Hi... I am creating a dummy project for collage. Here I had choosen my project as Jewelleryshoping. Now the scenerio is like that thier are jewellry item which I had display in table format with...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
9
by: dhtml | last post by:
I have written an article "Unsafe Names for HTML Form Controls". <URL: http://jibbering.com/faq/names/ > I would appreciate any reviews, technical or otherwise. Garrett --...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.