Create a survey form with unique code for single use

Remko74 09 Dec, 2018
Hi,
I like to create an online survey which can be filled in by people who received a unique code. Every unique code must be valid only one time. So once a visitor has used its unique (secret) code, the code can not be used again. In this way the survey can only be filled in once by people who received a special unique code.
Is that possible with ChroneForms? If Yes, how?
Thanks in advance
healyhatman 09 Dec, 2018
Yes it is. The link to the survey should include a unique code, for example a uuid (generate one in CF with {uuid:} ) in the URL. So it will be for example mysite.com/index.php?option=com_chronoforms6&chronoform=myForm&code=9810be4e-fbff-11e8-8eb2-f2801f1b9fd1

Then in your load event, check the database for that code. If it's not found, show an error. If it's found, load the form. Put the code in a hidden input. On form submit, check the database again - no code, no submission. Correct code, do whatever it is you have to do then delete the code from the database.
Remko74 10 Dec, 2018
Thanks for your reply. This comes close to what I was thinking of.
  1. people are invited by mail or email to participate in a survey with a unique code
  2. they go to the url mentioned in the invitation, fill in the code and click on a button (next)
  3. they participate in the survey and click on submit
  4. after submission the unique code is not valid anymore
The url must be simple so the chance of typing a wrong url is minimal. (i.e. www.simpledomain.com/survey). That is fairly easy to do. ((hidden) menu item linking to the form).
But then they have to enter the unique code. That code must be compared to a list of valid codes. At https://www.randomcodegenerator.com/ I can generate random codes, export them to a csv file and use them (one per letter) in the invitation.
It would be nice if I can import these codes to a table for use in ChronoForms. ChronoForms can compare the entered codes with the codes in the table.

[ins][strong]What is the easiest way to get these codes in the table?
How can I create an input field which compares the entered code with the codes in the table?[/strong][/ins]

When people type the wrong code, they will have to see a "wrong code" error message.
When people type an already used code, they will have to see a "already used" error message. But when that option makes it to complex , the wrong code message will be fine as well.
When people enter a valid code they will be forwarded to the survey.
After submitting the survey form, the used unique code must be deleted from the list or be marked as used.

How can I have ChroneForms removed a used code from the table so that it is not valid anymore when people want to use the code more than once?
(or....maybe to complex)....mark the code as used, so that there will be a difference between wrong typed codes and already used codes)

The bold and underlined questions are the points on which I am stuck. I hope you (or someone else) can help me with that.
[br]Thanks in advance.
healyhatman 10 Dec, 2018
Why make them type in the code at all? Why not just do what I said and pass the code in a URL parameter?

As to getting the codes from your CSV file into a database table, you should be able to sort that out in PHPMyAdmin or code it yourself in PHP. Or at least use PHP to load the data from the file. Doing that for you isn't the sort of thing I do for free.

To compare the code with the code in the table, just use a text input field. On submit, have a read data action looking for code:{data:code_field} or even better have the code in a URL parameter and put the read data in the form load action - same way using code:{data:url_parameter_name}

To delete from the table, use the "Delete Data" action. Or (not actually complex at all) use a Save Data action to update the database table, with the code as your where condition.
Remko74 10 Dec, 2018
There are several reasons that people have to type in the code themselves:
  1. The URL must look very simple (It must also remain accessible to the elderly and people with little knowledge of computers.)
  2. Some people don't know where to type the URL and enter the URL in a search engine (Google, Bing, etc...)
  3. When people enter the url in Google, they will see the main site with a link to the form. But there I can not use the unique url.
  4. Only invited people may participate in the survey, so they only have to access the form after entering the unique secret code.
The other suggestions will help me a little, but I still don't know where to type what when creating the form. But maybe with your tips and a little trial and error I come to the right result .

Thanks for your input. I really appreciate it.
Any additional suggestions, tip, step by step instructions, etc. are welcome of course....
GreyHead 11 Dec, 2018
Hi Remko,

I have a Unique ID action for CFv5 that generates short unique strings - unfortunately I've not yet worked out how to convert that to a CFv6 action.

If you have a CSV file of codes then you can import those into a table in your Joomla! database with a 'status' column. (There is an Excel extension available from the MySQL site that makes this pretty simple).

When you access a new code then you can change the status to 'used' or something similar so that you do not re-use it.

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