Please Login or Register to continue.


 form data to excel file using PHP:-

I am working on a PHP project. I want to generate a CSV  (excel ) file using HTML form. I am new to PHP development. I don't know how to save HTML form data to an excel file using PHP? I need your help to generate an Excel file from the HTML form.  

I elaborated hare that I will create an HTML form. The HTML form will contain the Name, Email, Address, Mobile no, etc. When someone click fills the form and clicks on the submit button it will produce an excel file and output. 

Kindly help me. 

(4.3K Points)
in PHP


1 Answer
(2.4K Points)

Save HTML  form data to excel file using PHP:- 

Ok! You are looking for "Save HTML form data into to excel file using PHP".Think about it, Excel ( CSV ) format is very useful to store the data in one file. There are a lot of ways to save the HTML form data into the excel file.

You can create a database table and retrieve the all data in one click after that you have to convert the database data into excel format.

But your question is different. Your solution is very easy. You can get the excel (CSV ) format without creating the database.

Create an HTML form.     The HTML form will contain the fields like 



 Mobile no,



You can add more fields in the HTML form. 

When someone fills the form and click on submit button the result will be an excel file.

The excel file will contain the all HTML form field data.  

 $Content = "Name,address,mobileno,email\n";

//set the data of the CSV

 $Content .= "$name,$address,$mobileno,$email\n";

 //set the file name and create CSV file

 $FileName = "Myfile-".date("d-m-y-h:i:s").".csv";

  header('Content-Type: application/csv'); 

  header('Content-Disposition: attachment; filename="' . $FileName . '"'

echo $Content;




Related Questions :-

Featured Items:-

Certificate system in PHP website | PHP scripts


Home Credito loan finance management multipurpose system in PHP


Result management system with Marksheet in PHP website | PHP Scripts


Your Answer

You can post your answer after login..