---プログラミング初心者です。
入力フォーム(form.html)から入力された内容を出力結果画面(receive.php)に反映させたいです。
phpファイルの内容が正しく反映されず、記載したコードがそのままブラウザに反映されてしまいます。
教えてください。
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>入力フォーム</title> </head> <body> 入力フォーム<br> <form method="post" action="receive.php"> 料理名:<input type="text" name="recipe_name" required><br> カテゴリ: <select name="category"> <option hidden>選択してください</option> <option value="1">和食</option> <option value="2">中華</option> <option value="3">洋食</option> </select> <br> 難易度: <input type="radio" name="difficulty" value="1">簡単 <input type="radio" name="difficulty" value="2" checked>普通 <input type="radio" name="difficulty" value="3">難しい <br> 予算:<input type="number" min="1" max="9999" name="budget">円 <br> 作り方: <textarea name="howto" cols="40" rows="4" maxlength="320"></textarea> <br> <input type="submit" value="送信"> </form> </body> </html>
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>出力結果</title> </head> <body> <?php // print_r($_POST); echo htmlspecialchars($_POST['recipe_name'], ENT_QUOTES); echo '<br>'; echo match ($_POST['category']) { '1' => '和食', '2' => '中華', '3' => '洋食', } . '<br>'; echo match ($_POST['difficulty']) { '1' => '簡単', '2' => '普通', '3' => '難しい', } . '<br>'; if (is_numeric($_POST['budget'])) { echo number_format($_POST['budget']); } echo '<br>'; echo nl2br(htmlspecialchars($_POST['howto'], ENT_QUOTES)); echo '<br>'; ?> </body> </html>
回答1件
あなたの回答
tips
プレビュー