Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/form.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ordland Euroboros  >  PHP GUI API  >  examples/form.php  >  Download  
File: examples/form.php
Role: Example script
Content type: text/plain
Description: An example form script
Class: PHP GUI API
Render HTML pages composed programmatically
Author: By
Last change: minor edit
Date: 1 year ago
Size: 4,739 bytes
 

Contents

Class file image Download
<?php

if(isset($_POST['submit']){
    echo 
"Your Username is: {$_POST['username']}";
    echo 
"<br>";
    echo 
"Your Password is: {$_POST['password']}";
    echo 
"<br>";
    echo 
"Your Confirmed Password is: {$_POST['password2']}";
    echo 
"<br>";
    echo 
"Your Email is: {$_POST['email']}";
    echo 
"<br>";
    echo 
"Your Confirmed Email is: {$_POST['email2']}";
    echo 
"<br>";
    echo 
"Your Gender is: {$_POST['gender']}";
    echo 
"<br>";
    echo 
"Your Country is: {$_POST['country']}";
    echo 
"<br>";
    if(empty(
$_POST['username'])) echo "<b>Error: You have not entered a username, please go back and fill in the blank.</b>";
    elseif(empty(
$_POST['password']) or $_POST['password'] != $_POST['password2']) echo "<b>Error: You have not entered a password, or you have not confirmed it successfully.</b>";
    elseif(empty(
$_POST['email']) or $_POST['email'] != $_POST['email2']) echo "<b>Error: You have not entered an email, or you have not confirmed it successfully.</b>";
    elseif(
$_POST['tos'] != "yes") echo "<b>Error: You have not yet agreed on the Terms of Services!</b>";
    else echo 
"<b>You have registered successfully!</b>";
    return;
}

$document = new Document("regform");
$form = new Form("myform");
$form->setAction("form.php");
$form->setMethod("post");
$form->setAlign(new Align("center""middle"));
$form->setLineBreak(FALSE);

$src = new URL("http://www.tivo.com/assets/images/abouttivo/resources/downloads/backgrounds/Green_bkgd_72rgb.jpg");
$field = new FieldSet();
$field->setLineBreak(FALSE);
$field->setBackground(new Image($src"back"300));

$field->add(new Legend("Required Field"));
$field->add(new Division(new Comment("Please enter your username here, it must be alphanumeric."), "username"));
$field->add(new TextField("username""admin"10));
$field->add(new Paragraph(new Comment("Please fill in your password confirmed password here.")));
$field->add(new PasswordField("password""password""123456"));
$field->add(new PasswordField("password""password2"));

$email = new Paragraph();
$email->setID("email");
$email->setFont(new Font(14"Times New Roman"));
$email->getFont()->setWeight("bolder");
$email->setForeground(new Color("#000080"));

$email->add(new Comment("Please type your email and confirmed email here."TRUE));
$email->add(new PasswordField("email""email"));
$email->add(new PasswordField("email""email2"));
$field->add($email);
$checkbox = new CheckBox("I agree to the terms of services""tos""yes""yes");
$field->add($checkbox);

$field2 = new FieldSet(new Legend("Additional Fields"));
$field2->setBackground(new Color("red"));

$radiolist = new RadioList("gender");
$radiolist->add(new RadioButton("Male""gender""male"));
$radiolist->add(new RadioButton("Female""gender""female"));
$radiolist->add(new RadioButton("Unknown""gender""unknown"));
$radiolist->check("unknown");

$countries = array("Britain""France""Germany""Italy""Spain""America""Canada""Russia""Australia");
$alias = array("gbr""fra""ger""ita""esp""usa""can""rus""aus");
$default "usa";
$dropdown = new DropdownList("country");
$dropdown->fill($countries$alias$default);

$comment2 = new Comment("Your Citizenship: "FALSE);
$comment2->setBold();
$comment2->setUnderlined();
$comment2->setForeground(new Color("yellow"));

$field2->add(new Comment("Your Gender: "FALSE));
$field2->add($radiolist);
$field2->add($comment2);
$field2->add($dropdown);
$field2->add(new Comment("Select an Avatar: "FALSE));
$field2->add(new FileField("avatar"));
$field2->add(new CheckBox("Receive System/Administrator Email""systememail""enabled"));

$submit = new Button("Register""submit""submit");
$submit->setLineBreak(FALSE);

$form->add($field);
$form->add($field2);
$form->add(new Image(new URL("../templates/icons/facebook.gif"), "facebook"20));
$form->add($submit);
$form->add(new Image(new URL("../templates/icons/twitter.gif"), "twitter"20));

$lang = new Comment("Registratio Form"FALSE);
$lang->setCentered();
$lang->setBold();
$lang->setUnderlined();
$lang2 = new Comment("Note: It is your own responsibility to protect your password!");
$lang2->setCentered();
$lang2->setForeground(new Color("red"));

$document->add($lang);
$document->add($form);
$document->add($lang2);
echo 
$document->render();

$links $document->getLinks();
$images $document->getImages();
$forms $document->getForms();
$tables $document->getTables();
echo 
"<center>The document contains:<br>";
echo 
"{$links->count()} links, {$images->count()} images, {$forms->count()} forms and {$tables->count()} tables.</center>";
?>