And are you sure it would it be
$fname = fopen("excelfile.xls",a+); and not
$fname = fopen("textlfile.txt",a+);?
its can be "anyfilename.anyextension" BUT behind the scene.. its actually writing a text file... Using commas as separators leads to .CSV file. (this can be opened in Excel)
If we want to use .xls as our extension to open in Excel, just replace those separators with tabs ---> "," to "\t"
Using commas is a standard CSV type that any SpreadSheet apps can open...
CORRECTION to my previous post it should be .csv not .xls since we are using "," as our seperator
2 next Q
THis is a CSV file.. can be opened with any spreadsheet app including Excel
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$templine = $name . ",". $age . "," . $phone . "," . $address . "\n";
if($fname = fopen("excelfile.csv","a+"))
{
fwrite($fname,$templine);
fclose($fname);
echo "Info added, thanks for your inp";
}
else
{
echo "We are experiencing tech difficulties :( ";
}
?>
xls file.. can be read in Excel.. not sure with other aps
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$templine = $name . "\t". $age . "\t" . $phone . "\t" . $address . "\n";
if($fname = fopen("excelfile.xls","a+"))
{
fwrite($fname,$templine);
fclose($fname);
echo "Info added, thanks for your inp";
}
else
{
echo "We are experiencing tech difficulties :( ";
}
?>
Dont forget quotes around "a+"
Good Luck
TommYNandA