Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Check email against external database before sending basic admin notification

  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
8 years 1 month ago #130528 by dweisser
I have a survey in which the respondent provides the email address of a third party in a short text answer.
It is the third party email to which I will send the basic admin notification.
A third party might not want to receive an email, so they need to be able to unsubscribe.
So, I set up a mysql database that can be updated with email addresses of those who would like to "opt out" or unsubscribe.
The problem I have is this: How can I check that database for "bad emails" before the respondent submits the survey and sends the basic notification?

I was thinking of one possible solution. On survey submit, I could call a .php script that checks the email database and then sends a "clone" of the basic email notification, but then I have a lot more work to do to recreate that notification in a separate .php file.
I'd love to hear community thoughts!
Thanks,
David
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #130538 by DenisChenu
Hi,

Need a plugin : afterSurveySubmitted event

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
8 years 1 month ago - 8 years 1 month ago #130540 by dweisser
I was heading down the rout of putting a button (.email_validate) on the survey to "validate the email". Respondent will push the button, call a .php script that makes the database check, and return a value of 1 or 0 depending on whether the "bad email" is present. I will update a hidden text question with the value and will only allow the survey to submit if the value is 1.

Everything works, except I'm having trouble returning the value to javascript via php. I have this in my temple.js.

$('.email_validate').click(function(){
//var email = document.getElementById('answer891188X349X2862SQ3').value;
var clickBtnValue = $(this).val();
var ajaxurl = ' www.domainname.com/surveyassets/email_op...=example@example.com ',
data = {'action': clickBtnValue};
$.post(ajaxurl, data, function (response) {
// Response div goes here.
var result = $.parseJSON(output);

alert(result + "<br>" + ajaxurl + "action performed successfully");
});
});

I'm getting an error in the console on the $.parseJSON line: Output is undefined. Any thoughts?
Last edit: 8 years 1 month ago by dweisser.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #130543 by DenisChenu
JS Nissue not LS linked but here :

$.post(ajaxurl, data, function (response) {
// Response div goes here.
var result = $.parseJSON(output);

You set response, but use output .....

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
8 years 1 month ago - 8 years 1 month ago #130544 by dweisser
Thanks Denis -
Unfortunately, I now get: Uncaught SyntaxError: Unexpected token Y

I added in DataType = JSON, and now while I get no errors - also don't get the alert with the results....

I'm struggling.
Last edit: 8 years 1 month ago by dweisser.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
8 years 1 month ago #130546 by dweisser
I got it! Man!!
The unexpected token Y was the first character in the return string "You successfully blah blah blah." I wasn't returning anything parseable, so that resulted in error. I can now prevent the email from being sent by making mandatory the field that will capture the returned data,. This will force the respondent to "push the button" to run the email validation script.
Thanks again!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 month ago #130616 by holch
Depending on the country your are in this could be considered spam. I just saw a ruling from a German court which considered the recommendation / send to a friend function in Ebay as unsolicited email and ruled against the company who's ebay account it was sent from (however, it was based on competition law, not sure if it would apply in other cases). I just wanted to let you know, that just offering an option to unsubscribe might not be enough.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose