form - controller.php - AJAX Search Code ~ Ajax Training, Learn Ajax Video Tutorials Online, Ajax Examples
Ajax Training, Learn Ajax Video Tutorials Online, Ajax Examples: form - controller.php - AJAX Search Code

form - controller.php - AJAX Search Code

<?php

require_once('../../lib/xmlajaxresponse.class.php');
require_once('../../lib/request.class.php');

$response = &new XMLAjaxResponse();
$request = &new HttpRequest();

$event = $request->getParameter('event');

if ($event && function_exists($event)) {
$event($request, $response);
}

function submitForm(&$request, &$response) {
$firstName = $request->getParameter('firstname');
$lastName = $request->getParameter('lastname');
$address = $request->getParameter('address');
$email = $request->getParameter('email');
$website = $request->getParameter('website');
$errors = array();

if (!$firstName) {
$errors[] = 'First Name is required';
$response->addElement('firstnamebox', 'className', 'fieldboxerror');
} else {
$response->addElement('firstnamebox', 'className', 'fieldbox');
}

if (!$lastName) {
$errors[] = 'Last Name is required';
$response->addElement('lastnamebox', 'className', 'fieldboxerror');
} else {
$response->addElement('lastnamebox', 'className', 'fieldbox');
}

if (!$address) {
$errors[] = 'Address is required';
$response->addElement('addressbox', 'className', 'fieldboxerror');
} else {
$response->addElement('addressbox', 'className', 'fieldbox');
}

if (!$email) {
$errors[] = 'Email is required';
$response->addElement('emailbox', 'className', 'fieldboxerror');
} else {
$response->addElement('emailbox', 'className', 'fieldbox');
}

if (!$website) {
$errors[] = 'Web site is required';
$response->addElement('websitebox', 'className', 'fieldboxerror');
} else {
$response->addElement('websitebox', 'className', 'fieldbox');
}

if ($errors) {
$response->addData('message', implode('<br />', $errors), 'fadeout');
} else {
//$response->addElement('message', 'style.display', 'none');
$response->addData('main', '<div id="successalert"><b>Thank You!</b><br />Registration has been completed.</div>', 'fadeout');
}

}

$response->doResponse();

?>

Related Posts by Categories

0 comments:

Useful Links on Adobe Flex

Your Ad Here

Latest Books on Adobe Flex