creating session in chronoforms to joomla session and how to use php code in custom code

anita123 25 Feb, 2015
Hello chronoteam,

I have 2 issues with me as below:

1) I have used simple one field form named "email" and checking this email field existence in another table using custom code action and redirecting it to one joomla article.

I have written php code in custom code as follows:-

<?php

$options = array();
$options['driver']    = 'mysql'; // Database driver name
$options['host']      = 'xxxxx'; // Database host name
$options['user']      = 'xxxxxx'; // User for database authentication
$options['password']  = 'xxxxx'; // Password for database authentication
$options['database']  = 'xxxxxxx'; // Database name
// $options['prefix'] = ''); // probably not needed
?>

{text1}

<?php

die;
$db = & JDatabase::getInstance($options);
$query = $db->getQuery(true);
$query
    ->select($db->quoteName(array('email')))
    ->from($db->quoteName('jo_chronoengine_chronoforms_datatable_download-form'))
    ->where($db->quoteName('email') . ' = '.$db->quote({text1}));
    
$db->setQuery($query);
$results = $db->loadObjectList();

if(!empty($results)){
header('Location: http://immocosta.be/index.php?option=com_content&view=article&id=122');
}else{
$currentSession = JSession::getInstance('none',array());
$currentSession->set("myvar","ssssss");
header('Location: http://immocosta.be/index.php?option=com_content&view=article&id=123');
}

?>


But somehow "where($db->quoteName('email') . ' = '.$db->quote({text1}));" is not working.

Please suggest on this that how to use the input field variable.

2) I want to add a session value in joomla session through the above php in custom code event. how can i acheive this.


thanks in advance.
GreyHead 25 Feb, 2015
Hi Anita,

1. You can't use the curly brackets syntax in PHP - use $form->data['text1'] instead.

2. You can use the Joomla! session methods to get/set values in the User Session.
<?php
$session = JFactory::getSession();
$session->get('name');
$session->set('name, 'value');
?>

Bob
anita123 26 Feb, 2015
Thanks BOB, 😀 😀

it was a great help to me.

U rock and whole chronoform team rocks and genius 🙂😃 😃
This topic is locked and no more replies can be posted.