上記のようにしたい
入力.htmlでチェック入れ送信→保存.phpでcsvに保存
発生している問題
チェックボックスの入力を保存できない
該当のソースコード
html
1<html> 2<head> 3 <title>入力</title> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5</head> 6<body> 7 <form method="post" action="hozon.php"> 8 ラジオ1 9 <input type="radio" name="radio1" value="1">1 10 <input type="radio" name="radio1" value="2">2 11 <br>ラジオ2 12 <input type="radio" name="radio2" value="3">3 13 <input type="radio" name="radio2" value="4">4 14 <br>チェック 15 <input type="checkbox" name="check[]" value="5">5 16 <input type="checkbox" name="check[]" value="6">6 17 <br><input type="button" onclick="submit();" value="送信"> 18 </form> 19</body> 20</html>
php
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> 2<html lang="ja"> 3<head> 4<meta http-equiv="Content-Type" 5 content="text/html; charset=utf-8"> 6<title>保存</title> 7</head> 8 9<body> 10保存しました 11<button type="button" onclick="history.back()">戻る</button> 12 <?php 13$fp = fopen("sample.csv", "a"); 14$text_name = $_POST['radio1']; 15fwrite($fp,"$text_name,"); 16$text_name = $_POST['radio2']; 17fwrite($fp,"$text_name,"); 18$text_name = $_POST['check']; 19fwrite($fp,"$text_name,\n"); 20fclose($fp); 21?> 22</body> 23</html>
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/20 02:11
2019/08/20 02:16