Index.php
Código
<?php require("require/Form_Generator.php"); Form::Start("index.php?ThisIsTheDestination", "POST", true); Form::textbox("TextBoxname", "TextBox Label", "", "TextBox Placeholder"); Form::textbox("TextBoxname", "TextBox Label", "TextBox Value", ""); Form::breakline("This is a break line!", "red"); Form::password("password", "Password", "", "Your Password"); Form::password("rpassword", "Repeat Password", "", "Repeat Your Password"); Form::breakline("Check if both passwords match!", "blue"); Form::select("selectionname", "Selection Label", array("Choice 1"=>"chc1", "Choice 2"=>"chc2", "Choice 3"=>"chc3")); Form::checkbox("checkboxname", "Checkbox Label", array("Choice 1"=>"chc1", "Choice 2"=>"chc2", "Choice 3"=>"chc3", "Choice 4"=>"chc4")); Form::breakline("Wasn't this usefull?", "green"); Form::submit("Register"); ?>
Dentro de la carpeta require.
Form_Generator.php
Código
<?php class Form { var $destination; var $method; var $enctype = ''; var $fmBody = ''; var $fmHeader; var $fmFooter; var $form; var $choices; var $names; var $options = ''; public function start($destination = '', $method = 'POST', $enctype = false) { if($enctype == true) { $enctype = 'multipart/form-data'; } echo '<form method="'.$method.'" action="'.$destination.'" enctype="'.$enctype.'"><table>'; } public function submit($value = "submit", $name = "") { echo '<tr><td></td><td><input type="submit" value="'.$value.'" name="'.$name.'"></td></tr>'; } public function textbox($name, $label = '', $value = '', $placeholder = '', $color = NULL) { echo '<tr><td><label for="'.$name.'"><font color="'.$color.'">'.$label.': </font></label></td><td><input id="'.$name.'" type="text" name="'.$name.'" value="'.$value.'" placeholder="'.$placeholder.'"></td></tr>'; } public function password($name, $label = '', $value = '', $placeholder = '', $color = NULL) { echo '<tr><td><label for="'.$name.'"><font color="'.$color.'">'.$label.': </font></label></td><td><input id="'.$name.'" type="password" value="'.$value.'" placeholder="'.$placeholder.'" name="'.$name.'"></td></tr>'; } public function breakline($tekst = NULL, $color = NULL) { echo '<tr><td colspan="2" style="text-decoration:underline; padding-top:5px; padding-bottom:5px;"><center><font color="'.$color.'">'.$tekst.'</font></center></td></tr>'; } public function select($sname, $label = '', $choices, $color = NULL) { echo '<tr><td><label for="'.$name.'"><font color="'.$color.'">'.$label.': </font></label></td><td> <select id="'.$sname.'" name="'.$sname.'"> '; foreach($choices as $name=>$value) { echo '<option value="'.$value.'">'.$name.'</option>'; } echo '</select> </td></tr>'; } public function radio($rname, $label = '', $choices, $color = NULL) { echo '<tr><td><label for="'.$rname.'"><font color="'.$color.'">'.$label.': </font></label></td><td>'; foreach($choices as $name=>$value) { echo '<input type="radio" name="'.$rname.'" value="'.$value.'"> '.$name.'<br>'; } echo '</td></tr>'; } public function checkbox($cname, $label = '', $choices, $color = NULL) { echo '<tr><td><label for="'.$cname.'"><font color="'.$color.'">'.$label.': </font></label></td><td>'; foreach($choices as $name=>$value) { echo '<input type="checkbox" name="'.$cname.'" value="'.$value.'"> '.$name.'<br>'; } echo '</td></tr>'; } { echo '<tr><td><label for="'.$name.'"><font color="'.$color.'">'.$label.': </font></label></td><td> <input id="'.$name.'" type="file" name="'.$name.'"> </td></tr>'; } { echo '</table></form>'; } } ?>
Cuando seleccionan los form como quieran, se genera una class, y se descarga automáticamente...