Limiting Entries Per User
Limiting Entries Per User
I have created a survey. Is there a way I could prevent a person from taking the survey multiple times? It is set up for anonymous persons to take the survey, so I'm thinking I need a way to limit the IP address to only one entry. Thank you as always....
Re: Limiting Entries Per User
The IP address will likely change every day, unless you can control the network and give fixed, static IP addresses to all possible participants' devices. This means users can take the survey again next day.
Additionally, IP addresses just identify a device (for a certain time) and not the user.
Also, IP addresses can be faked.
So, IP addresses cannot be used as bulletproof unique identifiers for identifying the user in most of the cases.
Additionally, IP addresses just identify a device (for a certain time) and not the user.
Also, IP addresses can be faked.
So, IP addresses cannot be used as bulletproof unique identifiers for identifying the user in most of the cases.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Limiting Entries Per User
Many applications use javascript to save a generated unique identifier as cookie or in localStorage. This id can be used to identify the browser for that user profile.
When saving a survey, store unique identifier as cookie or in localStorage.
When entering the site, read and check if that identifier has already been stored as cookie or in localStorage. If not, this may be a new user. If yes, that user will have been here before.
Caution: this is not bulletproof, too:
- users can delete the cookie or localStorage item
- users can use incognito browser
- users can use a different browser
- users can deny saving cookies
- this will just identify the user profile/browser combination
When saving a survey, store unique identifier as cookie or in localStorage.
When entering the site, read and check if that identifier has already been stored as cookie or in localStorage. If not, this may be a new user. If yes, that user will have been here before.
Caution: this is not bulletproof, too:
- users can delete the cookie or localStorage item
- users can use incognito browser
- users can use a different browser
- users can deny saving cookies
- this will just identify the user profile/browser combination
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Limiting Entries Per User
Ok, thank you for the guidance. This survey is limited to people in my company so I don't think that too much cheating will occur, but there are always the childish who will try to skew results.
Do you have any pointers on where I would look to find out how to design a cookie type of remedy?
Do you have any pointers on where I would look to find out how to design a cookie type of remedy?
Re: Limiting Entries Per User
LocalStorage:
https://www.w3schools.com/jsref/prop_wi ... torage.asp
You may also google for javascript fingerprint libraries which try to collect different browser and environment settings t for building a likely unique identification string ("fingerprint"). But I have never used such in real life projects.
https://www.w3schools.com/jsref/prop_wi ... torage.asp
You may also google for javascript fingerprint libraries which try to collect different browser and environment settings t for building a likely unique identification string ("fingerprint"). But I have never used such in real life projects.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Limiting Entries Per User
Once I figure out the code, which Hooks file would I include it in? My assumption is hooks/tablename - function tablename_header - case 'detailview'.
Am I even close??
Am I even close??
Re: Limiting Entries Per User
I'm referring to the localstorage method.
Re: Limiting Entries Per User
* Please note: for this article I did not create a "surveys" table but used an existing "employees" table. So, you will see "employees" here and there. Replace it by your specific table name.
Well, I guess you only want to deny insert if that user already has inserted once and not if she/he has entered the "add new" page without saving. So, we should not change detail view in any case but only after insert.
If it was my project, I'd start like this*:
Step 1: Create a "thank you page"
(1.1) You may create a custom page, for example survey_inserted.php:
file: survey_inserted.php
Code: Select all
<?php
include("language.php");
include("lib.php");
include("header.php");
?>
<div class="alert alert-success">Thank you for taking the survey!</div>
<script>
window.localStorage.setItem(' ', ' ');
setTimeout(function() {
window.location.href = "index.php";
}, 5000);
</script>
<?
include("footer.php");
Step 2: Change redirect after insert
Find the "Redirect after insert" value of your "surveys" table*:
(2.1) Change that value like this:
Code: Select all
survey_inserted.php?SelectedID=#ID#
From now on, users will see the new custom "thank you" page after insert and will be redirected to homepage after 5 seconds.
Step 3: Deny filling another survey
Now we have a flag in localstorage which indicates that we have inserted a survey before. If user tries to enter surveys in "add new" mode, we can read the flag and deny editing.
(3.1) create hooks/surveys-dv.js (or edit, if already exists):
file: hooks/surveys-dv.js
Code: Select all
redirectReturningUserTo("employees_view.php");
function redirectReturningUserTo(url) {
if (!jQuery("input[name='SelectedID']").val().length && window.localStorage.getItem(" ") != undefined) {
jQuery(".container > *").css("filter", "blur(5px) grayscale(1)");
setTimeout(function () { window.location.href = url; }, 100);
}
}
Test
(1) Insert a new survey (or enter the custom page manually):
You will see the "thank you message".
You will not see the localStorage setting unless you check application tab in developer tools of your browser.
(2) Try to create a new survey*:
Detail view in "Add new" mode will be blurred immediately and user will be redirected to Table View.
--
Additional notes and limitations
- The code shown here is a starting point for your own implementation
- Extension: You may also hide/remove the "add new" button in table view: create (or edit) hooks/surveys-tv.js, check existence of flag using .getItem function, then hide or remove element
Something like this (not tested) inside document.ready function of table-view-hook:Code: Select all
if (window.localStorage.getItem(" ") != undefined) jQuery("#addNew").hide();
- According to your specs, this solution will work for one (single) survey-table. Just in case you will have more than one survey in the future (a table per survey), you will have to change the key when using localStorage.getItem and localStorage.setItem functions according to the specific table name.
- As mentioned in my previous post(s), this is not bulletproof and can be hacked easily if a user has little knowledge about javascript and browser settings. But according to your specification this should be fine with your secure intranet environment.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Limiting Entries Per User
Sorry, I cannot edit my previous post any longer, but I'd like to add another idea:
- Extension (2):
If another insert is denied, instead of redirecting to table view, you can also...
(1) Create a new custom page telling the user that she/he cannot fill-in another survey
(2) Change the redirection (first line of step 3.1) to that new custom page
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Limiting Entries Per User
Thank you for all your hard work....I'll let you know how it works for me.
Re: Limiting Entries Per User
Holy Cow...that all worked great right out of the box. Thank you for such a clear and detailed resolution. I'm sure that others will be able to use this in their development.
You must have a giant brain!!
You must have a giant brain!!
Re: Limiting Entries Per User
Thank you for your feedback!
Great, I'm happy it works for you out of the box!
Great, I'm happy it works for you out of the box!
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools