using CC and CF with uid-field from database

bobmijwaard 19 Apr, 2009
I use ChronoForms to store information (from users) in a DB-table and ChronoConnectivity to get data out of this table and to do some calculations with the data. This calculation is directly done after submitting the data from the form into the database (same session).
Of course the user would like to see only his calculation, not the calculation from other DB-records.
I tried to use the uid-field from the DB to retrieve the correct record to do the calculation with.

My approach was in CF getting the uid with:
<?php
global $uid
$uid= JRequest::getVar('uid');
?>

in On Submit code - before sending email:

and using in CC in the where field:
where uid = '($uid)'


But that does not work.
Is above the best approach or could I better use cookies for this (and yes, how)
GreyHead 19 Apr, 2009
Hi bobmijwaard,

I'm assuming here that 'uid' is the Joomla user ID? Then try this in the Where bob
<?php
$user =& JFactory::getUser();
echo "WHERE `uid` = '".$user->id."'";
?>

Bob
bobmijwaard 19 Apr, 2009
The fields:
cf_id
uid
recordtime
ipaddress

are created by CF when creating a table from the CF component.

Your code does not work directly, but you show me a direction. I try and find out. If I do not have any succes, I 'll be back
GreyHead 19 Apr, 2009
Hi bobmijwaard,

Yes - that the ChronoForms unique ID for the record (a random string). To link a record to a user you probably need to save the Joomla user id in the table.

Bob
bobmijwaard 19 Apr, 2009
I have solved this issue by using the IP address:

<?php
$ip=$_SERVER['REMOTE_ADDR'];
echo "WHERE `ipaddress` = '".$ip."'";
?>


Normally this should work.
GreyHead 19 Apr, 2009
Hi bobmijwaard,

Should work Ok-ish - the problem with IP addresses is that they can be shared and they can change (my isp changes mine every week or so) so they aren't a true unique id.

Bob
bobmijwaard 19 Apr, 2009
I agree, but at this moment it is good enough to identify the user for the very moment.

A selection based on userid should be better, but the user can use the form without registering, so this user does not have an user-id (I guess)
This topic is locked and no more replies can be posted.