PHP Form Creator Manual

Here is the manual for the PHP Form Creator. This was designed in order to have a quick reference, as well as detailed information.

  1. Install
  2. Intro
  3. Long Form
  4. Short Form
  5. PHP
  6. JavaScript

Installing this into a website is as simple as downloading the files (download from the main product page), then uploading them to the root of your website.


Once this is installed on your server, simply include the PHP/Form.php file in pages you wish to use the PHP Form Creator in. If you are using the calendar widget, then including the CSS/Calendar.css and JavaScript/Calendar.js is also required. After including the required files, create a form by $form = new Form($fromFile, $xml), with $fromFile = true if $xml is a filepath, and false if it is a straight XML string.

The PHP Form Creator will transform any XML passed to it into Long Form, so you may feel free to use either Long or Short Form, or a mixture thereof. Please view the XML long form for more information on how all items work.

Long Form

This form of XML is the easiest to read. Most of it should be somewhat self explanitory, but is listed below just in case. Please view the examples page to see actual examples.

  • form - required - this is the root node.
    • method - defaults to post - how the form is submitted, be it post or get.
    • name - defaults to "form" + formNumber - the name of the form
    • encodetype - requires method = post - the encType of the form post data
    • style - defaults to "table" - accepts styles "table", "row", and "none" for formatting of the form.
  • input - required for usefullness - main child element of form, used to define the data
    • class - the class for the input element
    • disabled - if true, then element disabled
    • error - explained more below, but it is for defining an error in the form
    • id - the elements html id
    • javascript - explained more below, for giving javascript actions to input element
    • label - a label for the input element
    • name - the name of element, auto-assigned if one isn't given
    • php - a php name for this elements value for easy value retrieval upon submission, more explained later
    • style - in case form style should be overwritten on this element
    • tabindex - the tab index for this element
    • value - the default value of this item
    • type - defines what kind of input this item actually is (with example), available types and extra specific functions below
      • button - a button input element
        • type - "button", "reset", or "submit" as per normal html
      • calendar - used to make the following calendar widget for dates
        Calendar Example
        June 2022

      • checkbox - makes a checkbox as shown... also, makes it an array automatically as checkboxes are normally needed in that situation
        Checkbox Example
        • defaultchecked - if true, then this checkbox is checked by default
      • file - makes a file upload dialog. This will not save anything by default, but you can handle the stuff in your own PHP scripts, or a FileSave under this element to save it.
        File Example
        • filetype - file mime types accepted
        • save - for security purposes, it is recommended that you write your own file handling, however, this is included for a default with minimum security implimented. It shouldn't overwrite any files already there. Also, it is set not to save to the website if possible. Once more, highly recommended that you make your own security.
          • allowedsize - max file size
          • allowed - used to list allowed types - defaults to containing file→filetype
            • type - a single whitelisted mime type
          • extension - a valid extension type to allow
          • location - the location to save files to
      • hidden - a hidden form input, for when you need extra info (no example shown)
      • image - a form of submit, gets the X and Y coordinates. (no example shown here)
        • source - the image url
      • inputbutton - instead of <button> this simulates the <input type="button">
      • label - random label in case you need it for a section in the form
        Label Example
      • select - a select box
        Select Example
        • option - an option, as seen in above example
        • optiongroup - an option group, as seen in above example, may contain options as above
      • text - a standard text box
        Text Example
        • cols - number of columns this textbox is (the length of the textbox)
        • maxlength - maximum number of characters allowed in this text box
      • password - a standard password box, has same inner xml as a textbox.
        Password Example
      • radio - a radio button, same inner xml as a checkbox, also returns an array for PHP variable as it is an array setup for radios in normal HTML and PHP.
        Radio Example
      • reset - a reset button - it will reset the form back to how it was at the beginning of the page loading (doesn't go back to complete defaults, as defaults are overriden when a form is submitted).
      • submit - a submit button to submit the form
      • textarea - an area of text that you can tell what size it should be
        Textarea Example
        • cols - number of columns
        • rows - number of columns
  • error - it is possible to check if any of the form inputs have an error with $form→isErrored(); If true, you shouldn't do anything with the input, as this will also check if the form has been submitted.
    • condition - the condition that this error can checks, if it is an error of type normal
      • blank - default - item is not allowed to be blank
      • numeric - item must be numeric
      • alpha - item must use only alphabetic characters
      • alphanumeric - item must only use alphanumeric characters
      • float - item must be a float
      • int - item must be an int
      • double - item must be a double
      • long - item must be a long
      • date - make sure item is a valid datetime
    • message - a message to display if the error conditions are met
    • type - an error conditions type
      • normal - default - one of the conditions above
      • regex - a regular expression. The condition is in the form of a regular expression.
      • numchecked - a type to check if you want the number checked for a condition. If this is the case, then the xml should go condition→min/max. Min will automatically default to 0, and max to any number. It simply checks the size of an array.
Short Form

The short form was created for those who like less typing, and because this is meant to be a time saving device in all circumstances. The first thing for short form is that you may do xml attributes inside of it. After that, most of the stuff is just placed down to one letter. For instance, full form might read as seen below.


Whereas that same thing in short form could read.

<f a="form_page.php">
  <i t="text" n="Example" />
  <i t="submit" />

Beacuse of this, the following was created. Just look for what you want to replace.

  • action = a
  • class = c
  • checked = ch
  • condition = con
  • disabled = d
  • error = e
  • hidden = h
  • input = i
  • javascript = js
  • label = l
  • method = m
  • name = n
  • php = p
  • label = l
  • message = m
  • onblur = ob
  • onchange = och
  • onclick = ocl
  • ondblclick = odbl
  • onfocus = of
  • onkeydown = okd
  • onkeypress = okp
  • onkeyup = oku
  • onmousedown = omd
  • onmousemove = omm
  • onmouseout = omout
  • onmouseover = omover
  • onmouseup = omu
  • onselect = os
  • style = s
  • tabindex = t
  • value = v

This is the main reason besides error checking that this whole thing was originally created. Basically, the php tag allows you to name an element for use later without having to go through the $_POST and $_GET variables. As everything names automatically, you may use just the PHP variables and input types, along with possibly labels if you would like to create something that makes sense.

There are two ways to use the PHP variables. I recommend not using any until $form→isErrored() returns false, but after that has happened you may call $form→getPHPVariableArray() to retrieve an array of the variables with the names you gave via the PHP tag if you prefer to work with arrays. Or, you may instead call $form→getPHPVariable($phpNameFromXMLPHPTag) to retrieve a single PHP variable.


Of course, there was the javascript tag mentioned earlier, but not much was explained about it. Basically, the javascript tag will take any of the tags you would use in HTML anyway, and add that function to the element.

  • onblur - what to do when the element loses focus
  • onchange - what to do when the element changes
  • onclick - what to do when the element is clicked
  • ondblclick - what to do when the element is double clicked
  • onfocus - what to do when the element gains focus
  • onkeydown - what to do when a key is pushed down on this element
  • onkeypress - what to do when a key is pushed down and released on this element
  • onkeyup - what to do when a key is released on this element
  • onmousedown - what to do when the mouse click is started
  • onmousemove - what to do when the mouse moves on this element
  • onmouseout - what to do when the mouse goes away from this element
  • onmouseover - what to do when the mouse goes onto this element
  • onmouseup - what to do when the mouse click is released on this element
  • onselect - what to do when the element is selected