<html>
<head><title>form template test</title>
<style>
body,td,select,textarea,input,pre
{ font: 9pt "arial", "helvetica", sans-serif; }
.formButton { border: #999999 1px solid; }
.formText { border: #999999 1px solid; }
.formError { font-weight: bold; color: red; }
.formErrorRow { background: #eeeeee; }
.formNoError { color: green; }
TABLE { border: #999999 1px solid; }
</style>
</head>
<body>
<?php
include 'xmlForm.php';
$xslForm = join('', file('formCustomised.xsl'));
$xmlConfig = join('', file('formCustomisedDataConfig.xml'));
$xmlForm = new xmlForm($xmlConfig);
// do server-side validation
$data = $HTTP_GET_VARS;
if (!empty($data)) {
if ($data['formAction']=='cancel') {
print '<font size="+2">Action cancelled</font>';
} else {
$result = $xmlForm->validate($data);
if (!$result) print '<font size="+2">Validation Error</font>';
else print '<font size="+2">Data Accepted</font>';
$isValidated = 'yes';
}
} else {
print '<font size="+2">Please enter your details</font>';
$isValidated = '';
$data['formAction'] = '';
}
print '<hr noshade color="black" size="1">';
if ($data['formAction'] != 'cancel') { // only display form if action has not been cancelled
// prepare html form for display
$result = $xmlForm->xslTransform($xslForm, array('isValidated' => $isValidated));
if ($result) print $xmlForm->output;
else print $xmlForm->error;
}
?>
</body>
</html>
|