使用PHP在AWS上更新CSV文件

时间:2016-11-04 13:12:31

标签: php html

在更新用于存储表单数据的CSV文件时,我需要帮助。当文件在我的本地服务器上时,它工作得很好,但是当我上传到AWS时,它就停止将表单数据填充到CSV文件中。

这是我目前的代码:

<form action="processform.php" method="get" name="miform">
<div id="level_03b">
<div id="level_03bmain">
<div id="level_03b01">
    <input class="textboxstyle_01" type="text" placeholder="NAME" name="name" />*<br />
    <input class="textboxstyle_01" type="text" placeholder="EMAIL" name="email" />*
</div>
<div id="level_03b02">
    <input class="textboxstyle_01" type="text" placeholder="COMPANY NAME" name="companyName" />*<br />
    <input class="textboxstyle_01" type="text" placeholder="PHONE NUMBER" name="phoneNumber" />*
</div>
<div id="level_03b03">
<p><textarea class="textboxstyle_02" name="message" placeholder="MESSAGE" rows="20" cols="40"></textarea><br />Kindly supply info such as qty and interested products</p>
</div>

</div>
</div>
<div id="level_03c"><input type="submit" value="Submit" name="submitBTTN" /></div>
</form>

processform.php

<?php
$home = 'index.html';
$name = $_GET['name'];
$keys = array('name','email');
$csv_line = array();
foreach($keys as $key){
    array_push($csv_line,'' . $_GET[$key]);
}
$fname = 'bulk.csv';
$csv_line = implode(',',$csv_line);
if(!file_exists($fname)){$csv_line = "\r\n" . $csv_line;}
$fcon = fopen($fname,'a');
$fcontent = $csv_line;
fwrite($fcon, $fcontent);
fclose($fcon);
header('Location: '.$home);
?>

0 个答案:

没有答案