hi guys
i hope you can help me,on how to perform validation before data being written into the database.
similar to username ajax validation during registration. this will involve (2) two forms or lists from fabrik. before being saved on the table it has to be present on the other table
tried the code below but still nothing
table 1 = empenc_warranty //db table that will be used by the end user
table 2 = seak_keycode //db table that will have the keycodesboth list and forms are generated via fabrik
warranty_code = element of table 1 (user will encode) that will validate data from table 2
encrypted_keycodes = element of table 2 tha holds the keycodes.
thanks so much
i hope you can help me,on how to perform validation before data being written into the database.
similar to username ajax validation during registration. this will involve (2) two forms or lists from fabrik. before being saved on the table it has to be present on the other table
tried the code below but still nothing
table 1 = empenc_warranty //db table that will be used by the end user
table 2 = seak_keycode //db table that will have the keycodesboth list and forms are generated via fabrik
warranty_code = element of table 1 (user will encode) that will validate data from table 2
encrypted_keycodes = element of table 2 tha holds the keycodes.
Code:
$value = '{empenc_warranty___warranty_code}';
$option = array();
$option['driver'] = 'mysql';
$option['host'] = 'localhost';
$option['user'] = 'userco_game';
$option['password'] = '123456';
$option['database'] = 'neco_game';
$option['prefix'] = 'zyz1_';
$db = JDatabase::getInstance( $option );
// Best to use Joomla's query builder:
$query = $db->getQuery(true);
// Use COUNT(*) to count the # of records matched
$query->select("COUNT(*)")->from('seak_keycode');
// ALWAYS use $db->quote() for user inputted values - otherwise is a major security risk
$query->where('encrypted_keycodes = ' . $db->quote($value));
// Set the query to the db
$db->setQuery($query);
// Run the query and return a single value (the # of records matched)
$matched = $db->loadResult();
if ($matched > 0) {
// We found some records so return true
return true;
} else {
// No records found - return false.
return false;
}
thanks so much