PHP Classes

File: css-form_generator-example.php

Recommend this page to a friend!
  Packages of Darren Cline   Basic CSS Form Generator   css-form_generator-example.php   Download  
File: css-form_generator-example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Basic CSS Form Generator
Compose and generate HTML Forms with valid CSS
Author: By
Last change: had to switch method to lowercase, uppercase causes file to not validate, thanks mpabeelen at hotmail dot com for pointing that out.
Date: 22 years ago
Size: 1,676 bytes
 

 

Contents

Class file image Download
<? require 'form_generator.class'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>XHTML/CSS Form Generator Basic Example</title>
    <link type="text/css" rel="stylesheet" href="form.css" media="screen" />
    <style type="text/css">
    /* We use CSS in order to change the apperance of our fields by referrencing thier ID */
    form textarea#comments { width: 25em; height: 8em; }
    form input#submit { width: auto; }
    </style>
  </head>
  
  <body>
  <?
  // Form Properties
  $o = new form_generator();
  $o->name = "add_user";
  $o->method = "post";
  $o->action = $_SERVER['REQUEST_URI'];
  // Form Fields
  $o->input = array(
  array(
  'type'=>'text',
  'label'=>'Name',
  'name'=>'name',
  'value'=>$_POST['name'],
  'id'=>'name'
  ),
  array(
  'type'=>'password',
  'label'=>'Password',
  'name'=>'password',
  'value'=>'',
  'id'=>'password'
  ),
  array(
  'type'=>'select',
  'label'=>'State',
  'name'=>'state',
  'options' => array('OH'=>'Ohio','CA'=>'California','FL'=>'Florida'),
  'id'=>'state'
  ),
  array(
  'type'=>'textarea',
  'label'=>'Comments',
  'name'=>'comments',
  'value'=>'this is an assload of text that should show up in the textare as the current value',
  'id'=>'comments'
  ),
  array(
  'type'=>'submit',
  'label'=>'',
  'name'=>'Submit',
  'value'=>'Submit',
  'id'=>'Submit'
  )
  );

  $o->make();
?>
</body>

</html>