PHP Classes

File: formClientValidated.php

Recommend this page to a friend!
  Classes of Herman Veluwenkamp  >  xmlForm  >  formClientValidated.php  >  Download  
File: formClientValidated.php
Role: ???
Content type: text/plain
Description: Client Validation Example
Class: xmlForm
Generates a form in HTML.
Author: By
Last change:
Date: 14 years ago
Size: 1,099 bytes


Class file image Download
<head><title>form template test</title>
              { font: 9pt "arial", "helvetica", sans-serif; }
<script language="javascript" src="formClientValidated.js"></script>

include 'xmlForm.php';

$xslClientJSArray  = join('', file('formClientValidatedJsArray.xsl'));
$xslForm           = join('', file('formClientValidated.xsl'));
$xmlConfig         = join('', file('formDataConfig.xml'));

$xmlForm  = new xmlForm($xmlConfig);

// prepare javascript array for client-side validation
$result = $xmlForm->xslTransform($xslClientJSArray, array()); 
if ($result) print $xmlForm->output;

// do server-side validation as backup to client-side
$data = $HTTP_GET_VARS;
if (!empty($data)) {
  $result     = $xmlForm->validate($data);
  if (!$result) print "<h2>Validation Error</h2>";
  else print "<h2>Data OK</h2>";

// prepare html form for display
$result = $xmlForm->xslTransform($xslForm, array());
if ($result) print $xmlForm->output;
else print $xmlForm->error;