Contact
Code
<?PHP
include("Formitable.class.php");
$newForm =
new Formitable(
mysql_connect("server","user","pass"),"db","formitable_time"
);
//turn off suto submit
$newForm->autoSubmit = false;
//up the character count for normal text inputs
$newForm->strField_toggle = 130;
//turn off default error messages
$newForm->msg_insertSuccess = $newForm->msg_insertFail = '';
//set a different opening tag for errors
$newForm->err_pre = '<span class="errfield">';
//set field breaks to empty string
$newForm->setFieldBreak('');
//set up a validation method, set a few fields to validate
$newForm->registerValidation('required','.+','Input is required.');
$newForm->validateField('subject','required');
$newForm->validateField('email','required');
//set validation feedback method
$newForm->feedback='line';
//test the submitted form to provide custom feedback
if(isset($_POST['submit'])){
if(!isset($_POST['comments']) || $_POST['comments'] == ""){
$error = 'Comments field is empty.';
} else if ( $newForm->submitForm() == -1 ){
$error = 'Fix the errors noted above.';
} else if ( $newForm->submitForm() ){
$error = 'Your comments were sent.';
} else $error = 'Error sending email. Please send through SourceForge.';
$error = '<p class="err">'.$error.'</p>';
}
//print form using a file template
$newForm->printFromTemplate('contact.tpl');
?>
Template
<h2>Contact</h2>
<center><div class="box" style="width:460px;" id="contact">
{open_form}
<table width="460" cellspacing=0 cellpadding=0 border=0>
<tr>
<td width="50%">{setBreak:label:<br/>}{regarding}</td>
<td>{email,disabled="true"}</td>
</tr>
<tr><td colspan=2>{subject}</td></tr>
<tr><td colspan=2>{comments}</td></tr>
<tr><td colspan=2 align="right" valign="center">
{php:error}{close_form,Send Comments,class="plain",,}
</td></tr>
</table></form>
</div></center>
MySQL Table
CREATE TABLE `contacts` (
`ID` tinyint(3) unsigned NOT NULL auto_increment,
`regarding` enum('General','Site Feedback','Documentation','Examples','Bug Report',
'Security Suggestion','Feature Request') NOT NULL default 'General',
`email` varchar(50) NOT NULL default '',
`subject` varchar(120) NOT NULL default '',
`comments` text NOT NULL,
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
);