我正在尝试使用该fputcsv
函数将我的表单提交值处理到 .csv 文件。我没有收到任何错误,也没有将表单值保存到 data.csv 文件中。谁能看到我做错了什么的问题?
形式
<label for="location">How many Locations?</label>
<input id="location" name="loc" /><br />
<select id="when" name="day">
<option value="Sunday">Sunday</option>
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
</select>
<input type="checkbox" id="osecom" name="osecom" value="Yes" />
<label for="osecom">Online</label>
<input type="checkbox" id="item1yes" name="item1yes" value="Yes" /> Yes
<input type="checkbox" id="item1no" name="item1no" value="No" /> No<br />
<label for="chkitem1">mobile</label>
<input type="checkbox" id="item2yes" name="item2yes" value="Yes" /> Yes
<input type="checkbox" id="item2no" name="item2no" value="No" /> No<br />
<label for="chkitem2">policy? </label>
<input type="submit" title="Submit Form" value="" />
php代码
if(isset($_POST['submit'])) {
$data = implode(',', $_POST);
if( $fp = fopen('data.csv', 'a') ){
fputcsv($fp, $data);
}
fclose($fp);
}