Welcome, Guest
Username: Password: Remember me

TOPIC: email survey response to participant

email survey response to participant 2 years 2 months ago #83294

I would like to email a copy of the completed survey to the recipient upon submit. Is this possible?
The administrator has disabled public write access.

Re: email survey response to participant 2 years 2 months ago #83297

  • Ben_V
  • Ben_V's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 1081
  • Thank you received: 239
  • Karma: 76
Have a look at the doc and/or at this previous post
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Last Edit: 2 years 2 months ago by Ben_V.
The administrator has disabled public write access.

Re: email survey response to participant 2 years 2 months ago #83331

Hi Benitov,

This shows me how to send a copy to the admin, but not to the recipient. I would like to send a copy of the completed survey to the recipient.
The administrator has disabled public write access.

Re: email survey response to participant 2 years 2 months ago #83344

  • Ben_V
  • Ben_V's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 1081
  • Thank you received: 239
  • Karma: 76
look again at those links ;)
The way for e-mailing responses to participant is fully and correctly explained.
>Notification & data management
>>1.
>>>2.
Ben/
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
The administrator has disabled public write access.

Re: email survey response to participant 2 years 2 months ago #83364

  • eltito
  • eltito's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Hi,

You can adapt my example to your needs.
First, you need to put a callback on the message end screen. For this, see javascript code below. It will call a PHP script with the email, survey ID and the DB field name for email storage.
$(document).ready(function() {
  var d = new Object();
  d.email = '{INSERTANS:SGQA}';
  d.sid = '{SID}';
  d.fn = 'SGQA';
    $.ajax({
      type: 'POST',
      url: 'checkmail.php',
      data: d,
      success: function(t){console.log(t)}
    });
  });

Next, you need the server side script which will check and process sent datas. In my case, it delete all duplicated surveys for a given email address. You have to change it to your needs. I don't know how you could get a human readable resulte but it seems to be the same logic as my case.
$query = "SELECT $fieldName FROM {$dbprefix}survey_{$surveyid}\n"
. "WHERE $fieldName = ".db_quoteall(sanitize_email($email));
$result = $connect->Execute($query) or safe_die ($query."<br />".$connect->ErrorMsg());
if (($result->RecordCount()) > 0)
{
    $connect->Execute("DELETE n1 FROM {$dbprefix}survey_{$surveyid} n1, {$dbprefix}survey_{$surveyid} n2 WHERE n1.{$fieldName} = ".db_quoteall(sanitize_email($email))." AND n1.id > n2.id AND n1.{$fieldName} = n2.{$fieldName}");
    if ( $connect->Affected_Rows() ) {
        die('done');
    } else {
        die('fail');
    }
} else {
    die('useless');
}
The delete statement have to be replace by for example :
"SELECT n1.* FROM {$dbprefix}survey_{$surveyid} n1 WHERE n1.{$fieldName} = ".db_quoteall(sanitize_email($email))

This will get all the survey informations for an email address. I let you have a look at INSERTANS:SGQA on the wiki. The big part will be the mail creation, if you want a human readable email...

Hope it helps.
Regards.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.163 seconds
Donation Image