B
B
Berkutman2019-03-21 20:24:59
Drupal
Berkutman, 2019-03-21 20:24:59

Webform saving fields to text document?

Hello everyone, there is the following T.Z:
There is a web form, the user enters his full name in the appropriate fields.
It is necessary that each time the form is submitted, those fields (i.e. full name) are taken and updated in an existing file that is supposedly created at the url my-website/user.txt.
That is,
User 1 = Entered the full name in the corresponding fields and using ( RULES or some module) saves the entered results to a file at the url my-website/user.txt in the formUser1 LastName1User1Name1User1Patronymic1User2
= Entered the full name in the appropriate fields and using (RULES or some module) saves the entered results to a file by url my-website/user.txt in the formUser2 LastNameUserName2 MiddleNameUser2
We get the output of my-website/user.txt in the
formUserLastName1UserName1UserPatronymic1UserLastName2UserName2UserPatternName2 user is an example. It should display the full name of the user's instructions, i.e. Last name First name Middle name Last name First name Middle name , etc. Thank you. Drupal 7.* Webform 7.x-4.19

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2019-03-22
@Berkutman

function hook_webform_submission_insert($node, $submission) {
  $file = fopen(DRUPAL_ROOT . '/user.txt', 'a');
  $line = $submission->data[1][0] . ' ' . $submission->data[2][0];
  fwrite($file, $line . "\n");
  fclose($file);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question