I have created a substantial form using Chronoforms and the input and viewing of the information in an editable format is working great just using the form code section. When a record is edited, and that information is posted to the dbase it is creating a new record and not editing the old record. I thought I had made this change to the php but obviously not. Can anyone see what I need to do to the code to post to the current record. Individual logged in.
Andrew
Andrew
<?php
$user =& JFactory::getUser();
if ($user->id == 0)
{
//User not logged in, stop loading the form...
echo "You are not allowed to access this page. Please login first!";
return;
}
//Get an instance of the JDatabase object...
$db =& JFactory::getDBO();
//Build the SQL-query...
$query = sprintf('SELECT * FROM %s WHERE %s = %d LIMIT 1',
$db->nameQuote('jos_hive_profile'),
$db->nameQuote('cf_user_id'),
$user->id
);
//... load it, and get the result..
$db->setQuery($query);
$userData = $db->loadObject();
//Get the session storage, we'll need this to keep track of which database record we're editing:
$sess =& JFactory::getSession();
$sess->set('cf_id', $userData->cf_id, md5('chrono'));
//Now we've got all the data, proceed to the actual form:
?>
<?
$sess = JFactory::getSession();
$cf_id =& $sess->get('cf_id', 0, md5('chrono'));
JRequest::setVar('cf_id', $cf_id);
?>