Error: name =>
Enter your name (3-40 signs)
Error: email => Does not match /@/i
One fine day it will work :)
<pre>
<?php
// whatever you need...
define("FORM_INCLUDE_DIR", $DOCUMENT_ROOT . "/php/form/");
include_once(FORM_INCLUDE_DIR . "form.inc");
include_once(FORM_INCLUDE_DIR . "form_xmlfactory.inc");
$x = new form_xmlfactory($DOCUMENT_ROOT . "/projekte/form/cvs/xmlform.xml");
// reload the form with HTTP_[POST|GET]_VARS
$x->autoloadValues();
// check for errors
list($error_msg, $flags) = $x->validate();
if ($error_msg) {
// hmm, not send yet or not correct
// opening form tag
$x->Start();
// all the elements
printf("%20s %s\n", "Your name", $x->getElement("name"));
printf("%20s %s\n", "Your E-Mail", $x->getElement("email"));
printf("%20s %s\n", "Subject", $x->getElement("subject"));
printf("%20s %s\n", "Send me a note", $x->getElement("message"));
printf("%20s %s\n", "Contact wanted?", $x->getElement("contact"));
printf("%20s %s yes %s no\n", "Enjoy my site?", $x->getElement("radio_1"), $x->getElement("radio_2") );
$x->showElement("submit");
// closing form tag
$x->Finish();
// bail
print '<font color="red">';
foreach ($flags as $name => $message)
printf("%20s %s => %s\n", "Error:", $name, $message);
print '</font>';
} else {
// no errors
print "Well done darling.";
}
print "\nOne fine day it will work :)";
?>
</pre>
<hr>
<?php
highlight_string(implode("", file($DOCUMENT_ROOT . "/projekte/form/cvs/xmlform.php")));
?>
<hr>
<?php
print nl2br(str_replace("<" , "<", implode("", file($DOCUMENT_ROOT . "/projekte/form/cvs/xmlform.xml"))));
?>
<?xml version="1.0" encoding="UTF-8"?>
<form jsname="form1" action="/projekte/form/cvs/xmlform.php">
<javascript mode="strong">
<errorprefix>Uuups: \n\n</errorprefix>
<errorpostfix>\n\nPlease correct!</errorpostfix>
</javascript>
<elements>
<text name="text" elname="name" size="40">
<validation>
<length min="3" max="40">Enter your name (3-40 signs)</length>
</validation>
</text>
<text name="email" elname="email" size="40">
<validation>
<regexp reg="@" icase="true">Does not match /@/i</regexp>
</validation>
</text>
<select name="topic1" elname="subject" size="1" multiple="false">
<options>
<option value="form">Form stuff</option>
<option value="phpdoc">PHPDoc</option>
<option value="something">Hmm, ...</option>
</options>
<intros errormsg="Please select an option">
<intro value="-1">Please select ...</intro>
</intros>
</select>
<textarea name="message" elname="message" rows="5" cols="36" wrap="virtual">
Hey, your website is...
</textarea>
<radio name="likeit" elname="radio_1" checked="true">yes</radio>
<radio name="likeit" elname="radio_2">no</radio>
<checkbox name="contact" elname="contact" checked="true"/>
<submit name="submit" elname="submit">Send!</submit>
</elements>
</form>