Skip to content

Instantly share code, notes, and snippets.

@esedic esedic/controller.php
Last active Jan 4, 2016

Embed
What would you like to do?
<?php
function save()
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$message = $active->params->get('message');
$_data = array();
$_data = JRequest::getVar('jpainter', array(), 'post', 'array');
$query->insert('#__jpainter_data')
->columns(
array(
$db->quoteName('image'),
$db->quoteName('name_surname'),
$db->quoteName('age'),
$db->quoteName('city'),
$db->quoteName('parent_name_surname'),
$db->quoteName('address'),
$db->quoteName('parent_city'),
$db->quoteName('email')
)
)
->values("'". $_data['image'] . "','"
. $_data['name_surname'] . "','"
. $_data['age'] . "','"
. $_data['city'] . "','"
. $_data['parent_name_surname'] . "','"
. $_data['address'] . "','"
. $_data['parent_city'] . "','"
. $_data['email']."'");
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
JError::raiseError(500, $e->getMessage());
}
$lastRowId = $db->insertid();
$this->sendMail($_data, $lastRowId);
$this->setMessage($message);
$this->setRedirect(JRoute::_('index.php?option=com_jpainter&view=jpainter&Itemid='.$itemId, false));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.