Answer the question
In order to leave comments, you need to log in
How to save the values of a web form in an EXCEL file and send it as an attachment from a web form (1C-Bitrix Web Forms)?
Hello!
Please explain how you can implement the following (give practical examples): There is a web form. It is necessary that the data that was entered by the guest in the web form be saved to a file in the .xls format (with the appropriate field names) and sent in a letter (as an attachment) to the mail specified in the mail template after the web form is sent.
Answer the question
In order to leave comments, you need to log in
Dear Four-leafed, you have already asked this question before and are asking again. It is important to understand that the question turned out to be global and if the advice received for the first time is not clear to you, you should use a tricky technique. "Eat the elephant in parts"))))). I recommend it, because this approach was very useful to me, as a neophyte. So, how to send web form values as excel file? Break the task into subtasks. For example:
1) We get data from the form in a PHP script
2) We connect the PHPExcel library there
3) We create an Excel document using PHPExcel and add data from the form to it.
4) We save the created document where necessary
5) We send the created document to the recipient.
Are there any other steps you don't understand? Include them in the list. The result is a global task divided into subtasks. Something like this in your case looks like an elephant, divided into pieces))). It is much easier to digest them, to look for answers too. That is, if you do not understand the first paragraph - you are looking for answers on the net or ask a question here. Decided item 1? Move on to the second. Good luck.
I’ll add to Coderisimo that you can send a file “as if through a form” using multipart / form-data, if you need to attach everything to the email, it’s quite simple - fopen, fwrite, fclose, mail($headers = ....file);
If sending to another script, use multipart/form-data or curl. Everyone has their own jambs - curl tends to hang, so from time to time the second request does not reach, because the first one is still hanging, so you need to make several requests through while until the limit is exhausted or until a response is received.
multipart, in turn, is more difficult to write - you need to define a separator, and then stupidly send the content as a string, separating each file with a separator, a line break, then content, then 2 breaks, and a string - encoded in any way - the receiving script will have an array $ _FILES.
It is worth noting that, indeed, as they explained to me on the toaster, sending data via multipart / form-data will not make sending guaranteed in 100% of cases - it will only allow, in case of a successful request, to automatically upload the file to a temporary folder, so nothing interferes send data as json - if it is a text file, not an already encoded binary.
Another question is if the task is to save information from the form to Excel, in this case you do not need to send the file, you need to send the data to the script, which will make a file from the data.
But you can mess with sending the file right away, if you want to suffer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question