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
Name
Address,
Mobile no,
Email.
Etc.
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;
FORM DATA INTO CSV(EXCEL FILE )