Location: PHPKode > scripts > Forms from PHP > forms-from-php/formclass.php
<?
class doform {

// Usage:
// $frm = new doform();

function newform( $method, $action ) {

$text = "<form method=\"".$method."\" action=\"".$action."\">";

return($text);   

// Usage:
// $frm->newform( "POST", "myformproccessor.php" );

}
        
function endform() {

$text =  "</form>";

return($text);
 
// Usage:
// $frm->endform();

}

function text( $name ) {

$text = "<input type=\"text\" name=\"".$name."\">";

return($text);

// Usage:
// $frm->text("testing");
// creates a text box named testing

}
 
function pass( $name ) {

$text = "<input type=\"password\" name=\"".$name."\">";

return($text);

// Usage:
// $frm->pass("testing");
// creates a password box named testing

}
 
 
function radio( $name, $info ) {

foreach($info as $value) {
$text = $text.$value." <input type=\"radio\" name=\"".$name."\" value=\"". $value ."\"></input>";
}
 
return($text);

// Usage:
// $frm->radio( test, array("v1", "v2", "v3", "v4"));
// where test is the name of the key and v1-v4 are the values, completely
// expandable to hold as many values as needed...

}
 
 
function checkbox( $info ) {

foreach( $info as $key=>$value) {
$text = $text.$value." <input type=\"checkbox\" name=\"".$key."\" value=\"". $value ."\"></input>";
}
 
return($text);

// Usage:
// $frm->checkbox(array("test1"=>"v1", "test2"=>"v2", "test3"=>"v3", "test4"=>"v4"));

}
 
function select( $name, $info, $size ) {

$text = "<SELECT NAME=\"".$name."\" size=".$size.">";

foreach( $info as $value ) {
$text = $text."<OPTION>".$value;
}
 
$text = $text."</SELECT>";

return($text);
// Usage:
// $frm->select( test, array("v1", "v2", "v3", "v4"), 4);
// where test is the name of the key and v1-v4 are the values, completely
// expandable to hold as many values as needed...$size is how many to
// display on scrren without scrolling. Select Boxes...

}
 
function combo( $name, $info ) {

$text = "<SELECT NAME=\"".$name."\">";

foreach( $info as $value ) {
$text = $text."<OPTION>".$value;
}
 
$text = $text."</SELECT>";

return($text);

// Usage:
// $frm->combo( "test", array("v1", "v2", "v3", "v4"));
// where test is the name of the key and v1-v4 are the values, completely
// expandable to hold as many values as needed...Drop Down boxes...

}
 
function textarea( $name, $row, $col ) {

$text = "<TEXTAREA NAME=\"".$name."\" ROWS=".$row." COLS=".$col.">";

return($text);

// Usage:
// textarea( "testing", 6, 60 );
// Will create a textarea 60 colums wide and 6 rows high.

}
 
function submit( $name, $value ) {

$text = "<INPUT TYPE=submit NAME=\"".$name."\"VALUE=\"".$value."\"></INPUT>";

return($text);

// Usage:
// $frm->submit("submiter", "Submit Me!");
// Will create a submission button named submiter that says Submit Me!

}


function fclear( $name ) {

$text = "<INPUT TYPE=reset VALUE=\"".$name."\"></INPUT>";
 
return($text);

// Usage:
// $frm->fclear( "Reset Form" );
// Creates a reset button that says Reset Form...
 
}

}
?>
Return current item: Forms from PHP