我有一个 html 表单并使用 get 方法
如果用户选择鞋子选项值,我想将数据输入到 shoes_sales.txt,并将其余所有输入到衣服_sales.txt。不幸的是,这个数据没有出现在我的.txt
.
这是html表单:
<li class="form-line" id="id_16">
<label class="form-label-left" id="label_16" for="input_16"> Select choice </label>
<div id="cid_16" class="form-input">
<select class="form-dropdown" style="width:150px" id="input_16" name="q16_selectFrom16">
<option value="Shoes"> Shoes </option>
<option value="Clothes"> Clothes </option>
</select>
</div>
</li>
这是试图检索表单值的 php:
<?php
header("Location: thankforsumbitting.html");
if ($_GET['variable1'] == "shoes") {
$handle = fopen("shoes_sales.txt", "a");
}
else {
$handle = fopen("clothes_sales.txt", "a");
}
foreach($_GET as $variable => $value) {
fwrite($handle, $variable."=".$value."\r\n");
}
fclose($handle);
exit;
?>