Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Emily Brand  >  phpFormBuilder  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: A sample form to demonstrate the builder
Class: phpFormBuilder
Generate and process HTML forms
Author: By
Last change: changed filename
Date: 2010-02-17 08:12
Size: 4,070 bytes
 

Contents

Class file image Download
<?php
session_start
();

$_SESSION['page'] = 'index.php';    // Set the current page the form is on.

// Check if new form or submitted one.
if($_POST) {
  include_once(
"process.class.php");
  
$process = new Process($_POST);
  require_once(
"formdisplay.class.php");
  
$form = new FormDisplay("grad");
}
else {
  require_once(
"form.class.php");
  
$form = new Form();
}

if(
$_SESSION['error_array']) {
  echo 
"<div style='clear: both; color: red; margin-bottom: 20px;'>Errors have been found with your application: <br />";
  foreach(
$_SESSION['error_array'] as $k => $v) {
    echo 
"* $k<br />";
  }
  echo 
"</div>";
}

// Start Document.
$content .= $form->text('
  <!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>Graduate Application For 2010--2011 ExCEL Scholarship</title> 
   <style type="text/css"> 
     /* IF THIS DISPLAYS, PLEASE USE A NEWER BROWSER THAT RECOGNIZES style TAGS. */
     body { margin: 1in; font-size: 14px; width: 8.5in }
     input { margin: 0 5px 0 0px; }
     label {padding: 0 5px 0 0px; }
     .boxed { border: solid 1px }
     img { padding: 3px; margin: 2px }
     input[type="submit"] { text-align: center; margin: 0px auto; padding: 3px; display: block; cursor: pointer;}
   </style> 
   </head> 
   
  <body>
'
);

$content .= $form->text("<form name='grad' action='sample.php' method='post'>");
$content .= $form->text("<h3 style='clear: both'>Autobiographical Information</h3>");

$content .= $form->createTextBox("Name: ""name"$form->value("name"), 30200);
$sex = array("Male " => "male""Female " => "female");
$content .= $form->createRadioButton($sex"sex"$form->value("sex"));
$content .= $form->createTextBox("Born: Month: ""birthmonth"$form->value("birthmonth"), 22);
$content .= $form->createTextBox("Day: ""birthday"$form->value("birthday"), 22);
$content .= $form->createTextBox("Year: ""birthyear"$form->value("birthyear"), 44);

$content .= $form->linebreak();
$content .= $form->text("United States: ");
$citizen = array("Citizen or National " => "citizen""Lawful Permanent Resident " => "resident");
$content .= $form->createRadioButton($citizen"citizen"$form->value("citizen"));

$content .= $form->linebreak();
$content .= $form->text("Ethnic Background (Optional): ");
$ethnicity = array("Asian " => "asian""African-American " => "african",
                    
"Caucasian " => "caucasian""Hispanic " => "hispanic",
                    
"Multiracial " => "multiracial""American Indian or Alaskan Native " => "indianalaskan",
                    
"Puerto Rican " => "puertorican""Native Hawaiian or Pacific Islander " => "pacific",
                    
"Other " => "other",);
$content .= $form->createRadioButton($ethnicity"ethnicity"$form->value("ethnicity"));

$content .= $form->linebreak();
$content .= $form->text("Permanent Address: ");
$content .= $form->createTextBox("Number and Street: ""street"$form->value("street"), 7080);
$content .= $form->text("<br />");
$content .= $form->createTextBox("City: ""city"$form->value("city"), 4242);
$content .= $form->createTextBox("State: ""state"$form->value("state"), 22);
$content .= $form->createTextBox("Zip: ""zip"$form->value("zip"), 55);

$content .= $form->linebreak();
$content .= $form->createTextBox("Home Phone: ""homephone"$form->value("homephone"), 1015);
$content .= $form->createTextBox("Cell Phone: ""cellphone"$form->value("cellphone"), 1015);
$content .= $form->createTextBox("E-mail address: ""email"$form->value("email"), 4060);

$content .= $form->createSubmit("submitForm""Submit Your Application");

$content .= $form->text("</form> ");

$content .= $form->text("</body> </html> ");

echo 
$form->finalizeForm($content);