Tiny Form Class
I created this form class for a project I was doing that used multiple fields. Now let's face it, making a variable for over 30 fields is just rediculous. This simple form class is meant to simplify your life! You can make as many fields as you want in your HTML and have them either emailed to you or inserted into your database.
Here's how to use it.
So you've got your HTML form (on a .php page) that looks like this:
Sending as Email
If you're going to be using this to email your data then you will want to add this snippet of PHP code.
if(isset($_POST['send'])){
// This method will send all your data to an email in a table based layout.
$form = new Form();
$form->type('email'); // Type of submission
$form->subject('Contact Form'); // Subject of the email.
$form->sendTo('your@email.com'); // Who to send the data to.
$form->submitBtn('send'); // Name field on the submit input.
$form->send(); // EXECUTE!
}
Sending to Database
If you will be using the class for inserting the data into your database, then use this snippet of PHP code. You must make sure that each input name in your HTML is the same as the field name in your database. Example: <input type="text" name="firstname" /> is your HTML, you must have the fieldname 'firstname' in your database so it knows where to put the data.
if(isset($_POST['send'])){
$form = new Form();
$form->type('database'); // Type of submission.
$form->dbtable('tablename'); // Name of the table in the database.
$form->submitBtn('send'); // Name field on the submit input.
$form->send(); // EXECUTE!
}
One Sexy Response to Tiny Form Class
Feel free to put in your 2 cents. I need cash.
Code must be put in between <code> </code> tags or there will be no soup for you.




had this to say...
hj