duplicate data with chronoforms

borricos 13 Apr, 2019
Hi,

First of all, excuse me for my English.

I allow myself to ask because I did not find the answer to my question on the forum.

Here is my problem :

In a registration form for a competition, 2 players must enter their license number.
If these players entered their numbers liecence always in the same order, it would not be a problem since I would create a unique key (combination of 2 license numbers).
The problem is that we do not know in which order they will enter the players and because of this, impossible to create a combined key with 2 fields since if player 1 -> lience = 1111 and player 2 -> license = 2222
we would have either the key "11112222" or "22221111".

My question is :

How to check in a form chronoforms when the registration will be sent, if a player is already registered and how to return a message indicating that the registration is not taken into account since the player 1 or the player 2 is already registered ? (The player's license already exists in the database).

Thank you for your reply.
Fabrice
Belgium
Max_admin 13 Apr, 2019
Hi Fabrice,

There is a "Read data" action which you can use to read from a database table based on some conditions, if a record is found you can display a message and stop the form processing.

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
borricos 13 Apr, 2019
Thank you for your quick reply.

However, I have tested this option and apparently you can test a condition against a value.
How to test if the license fields of player 1 or license of player 2 entered in the form already exist in the database, then do not save the record.
healyhatman 13 Apr, 2019
Well it would be

{data:licence1}{data:licence2} OR {data:licence2}{data:licence1}
borricos 13 Apr, 2019
Thank you for the help and I understood that but my problem is to build the instruction that tells me:
if the value entered in the form with {data: license1} OR {data: license2} already exists in the table
then do not take the registration into account.

Fabrice
healyhatman 13 Apr, 2019
In the Found event of the read data put an error message and an event load.
Max_admin 13 Apr, 2019
You want to cancel saving of both of them or of the existing player only ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
borricos 13 Apr, 2019
The 2 players are part of the same record and if one of them already exists in the database, 
the form that is filled must not be registered in the database and a message informing the user must appear. Thank you for your help.
Max_admin 13 Apr, 2019
Then you need a "Read data" and add 2 conditions with OR parameter between them:
license_field = {data:license1}
OR
license_field = {data:license2}
And in the "found" event you can add, first a message action to display an error then an "Event loader" to reload the form

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
borricos 13 Apr, 2019
Despite having set the condition and the license number already exists, the record is added to the database.
I attached to this message the screenshot of the Read Data in my form.duplicate data with  chronoforms image 1
healyhatman 13 Apr, 2019
What did you put in the "found" event for that read data action?
borricos 13 Apr, 2019
Here's what I put in the item foundduplicate data with  chronoforms image 2
healyhatman 13 Apr, 2019
And what else? Did you put an event load in there to go back to your load event if there's an error?
borricos 13 Apr, 2019
I do not understand what you mean. I just want the data entered on the form not to be saved in the database
if one of the two licenses exists. Once again, thank you for your precious help.
healyhatman 13 Apr, 2019
OK so you need to put an EVENT LOAD action after the error message, to tell it to go back to the previous page if there's an error.

OR if you still want everything else in your submit event to happen, then put your save data action inside the "not found" event of your read data action.
Max_admin 14 Apr, 2019
How did you translate all the interface ? that may have broken some features because not all strings can be changed!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
borricos 15 Apr, 2019
Answer
1 Likes
Hi Max,
Sorry for this late response but I was not available this Sunday.

I applied the instructions you gave me and everything seems to work as I wish.
A big thank you for this precious help.

Best regards,

Fabrice
This topic is locked and no more replies can be posted.