Forums

Updating database record

mieszko 26 Feb, 2016
Hi!
I'm trying to do an e-mail verification in my form. I've got 3 additional posistions in database uid, check_uid and verified. I also added verify event . In custom code I create an unique id and assign it to uid. In e-mail to user I send a link:
<a href='http://mysite.com/index.php?option=com_chronoforms5&chronoform=form_name&event=verify&check_uid={uid}' >Click to verify</a>
Then in a verify event I want to assign check_uid to proper record, but CF creates a new one with only this field filled.
I have DB Read and DB Save in on found event inside. I suppose that I have to add some update conditions in DB Save, but no idea what code should it be.
How to repair it?
Thank you in advance, and sorry for my English,
Mieszko
GreyHead 26 Feb, 2016
Hi Mieszko,

I think that you need to add code in the Conditions box of the DB Save like this
<?php
return array('check_uid' => $form->data['check_uid']);
?>
That should identify the record with the matching uid

Bob
mieszko 27 Feb, 2016
Hi Bob,
thank you for your help, but it still doesn't work. When I added this code to update conditions, the check_uid field is not added to any record.
Maybe some screenshots will bu useful:

GreyHead 27 Feb, 2016
Hi Mieszko,

I'm rather lost about the purpose of this.

The reason that uid is being updated is that you have the data in $form->data['uid'] - if you want to save that to check_uid then you need to copy the data
<?php
$form->data['uid'] = $form->data['check_uid'];
?>

Bob
mieszko 27 Feb, 2016
Hi Bob,
maybe I do it wrong way. I think I should check if check_id from the link is the same as uid in database and then change the verified field on true. So check_uid in database isn't necessary. But still I don't know how to change verified field in proper place.
I am new in CF so sorry for my lack of knowledge.
GreyHead 27 Feb, 2016
Hi Mieszko,

You can set the value of $form->data['verified'] to 'true' or 'false' if that is what you need. I'm afraid that I still don’t understand what you need to do :-(


Bob
Max_admin 07 Mar, 2016
Answer
But still I don't know how to change verified field in proper place.
if you want to update an existing record then you must pass the value of the primary key of this record, so say you want to update "Verified" for record with id = 5 then you need to pass this data in a "custom code" action before the "db save" action:

<?php
$form->data["id"] = 5;
$form->data["verified"] = 1;
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.