teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

不適切なタグの削除

2021/06/08 11:08

投稿

ranerane0101
ranerane0101

スコア70

title CHANGED
File without changes
body CHANGED
File without changes

1

ファイル追加

2021/06/08 11:08

投稿

ranerane0101
ranerane0101

スコア70

title CHANGED
File without changes
body CHANGED
@@ -49,4 +49,86 @@
49
49
 
50
50
 
51
51
 
52
+ ーーーー追記ーーーー
53
+
54
+ form.php
55
+
56
+ ```ここに言語を入力
57
+ <!DOCTYPE html>
58
+ <html lang = "ja">
59
+ <head>
60
+ <meta charset="UTF-8">
61
+ <title>入力フォーム</title>
62
+ </head>
63
+ <body>
64
+ 入力フォーム<br>
65
+
66
+ <form method="post" action="add.php">
67
+ 料理名:<input type="text" name="recipe_name" required><br>
68
+ カテゴリ:
69
+ <select name="category">
70
+ <option value="">選択してください</option>
71
+ <option value="1">和食</option>
72
+ <option value="2">中華</option>
73
+ <option value="3">洋食</option>
74
+ </select>
75
+ <br>
76
+ 難易度:
77
+ <input type="radio" name="difficulty" value="1">簡単
78
+ <input type="radio" name="difficulty" value="2" checked>普通
79
+ <input type="radio" name="difficulty" value="3">難しい
80
+ <br>
81
+ 予算:<input type="number" min="1" max="9999" name="budget">円
82
+ <br>
83
+ 作り方:
84
+ <textarea name="howto" cols="40" rows="4" maxlength="150"></textarea>
85
+ <br>
86
+ <input type="submit" value="送信">
87
+ </form>
88
+ </body>
89
+ </html>
90
+
91
+
92
+ ```
93
+ receive.php
94
+
95
+ ```ここに言語を入力
96
+ <DOCTYPE html>
97
+ <html lang="ja">
98
+ <head>
99
+ <meta charset="UTF-8">
100
+ <title>出力結果</title>
101
+ </head>
102
+ <body>
103
+ <?php
104
+ //print_r($_POST);
105
+ echo htmlspecialchars($_POST['recipe_name'],ENT_QUOTES,'UTF-8');
106
+ echo "<br>";
107
+ if($_POST['category'] === '1') echo "和食";
108
+ if($_POST['category'] === '2') echo "中華";
109
+ if($_POST['category'] === '3') echo "洋食";
110
+ echo "<br>";
111
+ if($_POST['difficulty'] === '1') {
112
+ echo "簡単";
113
+ } elseif($_POST['difficulty'] === '2'){
114
+ echo "普通";
115
+ } else{
116
+ echo "難しい";
117
+ }
118
+ echo "<br>";
119
+ if(is_numeric($_POST['budget'])){
120
+ echo number_format($_POST['budget']);
121
+ }
122
+ echo "<br>";
123
+ echo nl2br(htmlspecialchars($_POST['howto'],ENT_QUOTES,'UTF-8'));
124
+ echo "<br>";
125
+ ?>
126
+ </body>
127
+ </html>
128
+ ```
129
+
130
+ 書籍でreceive.phpはファイル一覧みたいなところで含まれてないように見えたのですが念の為解決の一助となること祈って載せておきます。
131
+
132
+
133
+
52
134
  開発環境 Windows Xammp php7.x