【发布时间】:2012-07-17 09:49:54
【问题描述】:
我想将 HTML 表单的输出放在一个 csv 文件中,该文件的标题名称为:“NAME”、“EMAIL”、“WEB”。但是下面的 PHP 代码不起作用。任何机构都可以帮忙吗?
<?php
$fp = fopen("my_file.xls", "a");
$name = $_POST['name'];
$email = $_POST['email'];
$web = $_POST['web'];
if (!$fp) {
print("Could not open to file");
exit;
}
fput($fp, "NAME", "EMAIL",'WEB");
fputcsv($fp, $name, $email, $web);
print("Thanks you ");
fclose($fp);
?>
我尝试将my_file.xls 替换为my-file.csv。提交 HTML 表单后,输出为空白 CSV 文件。
预期:form 中带有标头的逗号分隔值。
请帮我定位问题。
【问题讨论】:
-
"PHP 代码不工作" -> 错误是什么?
标签: php csv xls forms http-post