About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / MailForm: The Sitellite Form API

MailForm: The Sitellite Form API

All we have left to do now is to actually DO something with the form once it has been submitted by a visitor to our site.  We do this in the onSubmit() method of our form class.  Let's use an example that would be appropriate for our form and have it email us the visitor's message.

<?php

class WebappContactForm extends MailForm {
function WebappContactForm () {
parent::MailForm ();

// create form widgets here
$this->parseSettings ('inc/app/webapp/forms/contact/settings.php');
} function onSubmit ($vals) { // handle form action here @mail ( 'you@yourWebSite.com', 'Contact Form', $vals['message'], 'From: ' . $vals['name'] . ' <' . $vals['email'] . '>' ); page_title ('Message Sent'); echo '<p>Your message has been sent. Thank you!</p>'; } } ?>
Now you should have a working contact form.  In the real world, you would want to check that the mail() function actually worked, and you would also want to move your response message into a template, for the sake of cleanliness.  But for a short example, I'm sure you'll forgive my poor habits. :)

As you can see, building forms in Sitellite is very straight-forward, but very powerful as well.  The real pay-off comes when you start building longer forms needing more advanced functionality and validation, and multiple-screen forms (ie. chaining multiple forms together), because no matter the form size, your code remains short and readable, and your forms remain easy to maintain.

Page 1: Sitellite features one of the mo...
Page 2: A basic MailForm file begins wit...
Page 3: In MailForm, you can define form...
Page 4: Lets say we want to verify that ...
Page 5: All we have left to do now is to...

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.