About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Building a Shout Box in Sitellite

Building a Shout Box in Sitellite

Step 3: Creating Our Shout Box Form

Before we can even display our Shout Box, we'll need a way to create some entries. In the "forms" folder, create a sub-folder named "add". In that folder we'll be creating three files:

access.php
Contains the access permissions for our form
index.php
Contains the PHP code for our form
settings.php
Contains the form definition, from which the form will automatically be generated

First, the access.php file:

sitellite_status = approved
sitellite_access = public
sitellite_action = on

This just tells Sitellite that we want the form to be public and visible by anyone.

Next, our index.php file:

<?php

class ShoutboxAddForm extends MailForm {
function ShoutboxAddForm () {
parent::MailForm ();
$this->parseSettings ('inc/app/shoutbox/forms/add/settings.php');
}
function onSubmit ($vals) {
db_execute (
'insert into shoutbox
(id, name, url, ip_address, posted_on, message)
values
(null, ?, ?, ?, now(), ?)',
$vals['name'],
$vals['url'],
$_SERVER['REMOTE_ADDR'],
$vals['message']
);

header ('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
}

?>


This class will generate the Shout Box message submission form, as well as handle the posting of the message submissions. The onSubmit() method inserts the message into the database, then forwards the user to the screen they originally came from, which will have refreshed to include their message.

Now, we need to define the form in our settings.php file:

[Form]

[name]

type = text
alt = Your Name

[url]

type = text
alt = URL

[message]

type = text
alt = Your Message

[submit_button]

type = submit
setValues = Submit


Our form should now be ready. To see it, you can call it from the browser address bar via:

http://www.example.com/index/shoutbox-add-form


Page 1: What is a Shout Box?
Page 2: Step 3: Creating Our Shout Box Form
Page 3: Step 4: Displaying the Shout Box
Page 4: Step 5: Adding Your New Shout Box to Your Web Site

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.