Featured Posts

FuelPHP Command Line Oil with Windows BAT File And... I have been using the Codeigniter PHP MVC framework for awhile now and have started to realize I need some extra features that are not built in by default.  A few weeks ago...

Readmore

PHP Class To Build HTML Forms I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help...

Readmore

Codeigniter Library to Read CSV File I recently posted some code to Github that I created for use in Codeigniter. I built a library that can be used to read CSV files, extract the data you need, and return a...

Readmore

Using PHP Curl To Check Apple Site To See If My Extension... A few weeks ago (probably closer to months now) I built a Safari extension.  I also submitted it to Apple to see if it can be listed on their Safari extensions page.  I...

Readmore

Safari Extensions - Puni.co URL Redirection For anyone interested in URL redirection services and Safari Extensions, here is a service offered by TheBizzTech LLC.  We have made a Safari Extension that uses the free puni.co...

Readmore

TheBizzTech Rss

PHP Class To Build HTML Forms

Posted on : 29-04-2011 | By : TheBizzTech | In : Github, HTML, PHP, Programming

Tags: , , , , ,

3

I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help make PayPal buttons easier to built into PHP scripts.  I have not looked at this script much since the summer of 2010, but hope to dust it off soon.

Here is a simple example of how to use the class that you can download from Github here, https://github.com/thebizztech/htmlform


<?php
/**
* TheBizzTech
*
* This example utilizes the open source htmlform PHP class built to make building HTML forms easier
*
* @author		Jason Michels
* @link		http://thebizztech.com
*/

//To use the htmlform class you first need to include the file
require("htmlform.php");
?>
<html>
<body>
<?php
// Initialize form class
$form = new htmlform();
// Begin the form and pass array of values
$form->begin_form(array("name"=>"myform","action"=>"index.php","method"=>"post","target"=>"thebizztech"));

// To create a new label include the element id in the "for" array value
$form->form_label(array("for"=>"1stid","text"=>"This is a label: "));

// To create an input field pass array with any standard attributes. The class will check to see which ones are set
$form->form_input(array("type"=>"text","id"=>"1stid","class"=>"1stclass","name"=>"1stname","value"=>"this is the value"));

// Another form input example
$form->form_input(array("type"=>"submit","id"=>"submitform","class"=>"submitform","name"=>"submit","value"=>"Submit Form"));

// Example of a form button
$form->form_button(array("type"=>"button","value"=>"Awesome","text"=>"Awesome button"));

// End of form. This will take one parameter allowing you to add html after the form such as a line in the example
$form->end_form("<hr />");
?>
</body>
</html>