Form data send as file attachment

Topics: Developer Forum, Project Management Forum, User Forum
Aug 7, 2013 at 8:09 AM
Hi guys,

I want to create a form that when submit button is clicked, the data automatically is sent to a formatted file in excel on my server.

Basically, I want to create a resume page and it needs to be in a pre-formatted style that will be used internally in the company...

I tried to find this topic in many places but couldn't find something that really gives me a good solution for this problem.

I'm brand new to php, so could someone help me on that please?


1 - User fill out the form

2 - Submit the form ---> creates Excel file (with pre-formatted style)

3 - Sends the file as attachment to my e-mail and server

I know it might be quite hard to solve that, but i really appreciate if you can give me some help.
Aug 7, 2013 at 12:12 PM
You can have a preformatted Excel file on your server (containing the styles, headers,... All that is fixed)
The script that receives the data (when the user clicks the submit button) can open this file, complete with data provided by the user and save it under another name.
Sending email is a subject well away from the use of PHPExcel, but your favorite search engine can give you thousands of responses: send an Excel file is exactly the same as any file.

To return to PHPExcel, the 07reader.php example shows you how to open an Excel file and how to save it. the 01simple.php sample shows you how to fill cells.
A bit works these aspects, then we will see which poses problem.
Mar 25, 2014 at 5:15 AM
Sorry, but i still didn't get that. I've been looking for an answer during this time but i couldn't find it.
Could you give me a more specific explanation?

Basically, I have these fields in my html form:

Photo (defined size)
Terms of agreement checkbox


when the user press "submit", the data needs to be saved in a excel file, (named according to the Name field filled.xls). Then, the created file needs to be sent as an email attachment automatically to an specific address (ex: I don't want the user to see the filled data on the screen on saving it on desktop, just sending it directly to email address and a specific server path location.
Apr 7, 2014 at 1:37 PM
Create with Excel a file containing the invariant elements (headers of columns, borders of cells, etc.). Copy this file to a directory on your server, to a place where PHP has the right to read.

When your user clicks the Send button, the data is sent to the script indicated in the form's action property.
In this script:
-You open your Excel file (see the first part of the example 07 if you do not know how to proceed),
-you filled the cells required with the data transmitted by the form. If these data are not in utf-8, encodes them in this format. See the example 01 for write access to the cells.
-You save the file (at a place where PHP has the right to write...) under the desired name (if you use the name provided by the user, checks that there are no characters the file system cannot handle or could be misinterpreted). See the second part of the example 07 to complete the save.

Actually, I do not write about sending mail... But as in eight months, you have not written a single line of code, I do not see the interest to now address this point.