質問編集履歴
1
htmlのコードを記載させていただきました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,7 +9,119 @@
|
|
9
9
|
|
10
10
|
(図2の二行目です)
|
11
11
|
### 該当のソースコード
|
12
|
+
```html
|
13
|
+
<!DOCTYPE html>
|
14
|
+
<html lang="ja">
|
15
|
+
<head>
|
16
|
+
<title>お問い合わせフォーム</title>
|
17
|
+
<link rel="stylesheet" href="./css/style.css" type="text/css">
|
18
|
+
</head>
|
12
19
|
|
20
|
+
<body>
|
21
|
+
<h1>お問い合わせフォーム</h1>
|
22
|
+
<?php if( $page_flag === 1 ): ?>
|
23
|
+
|
24
|
+
<form method="post" action="">
|
25
|
+
<div class="element_wrap">
|
26
|
+
<label>氏名</label>
|
27
|
+
<p><?php echo $_POST['your_name']; ?></p>
|
28
|
+
</div>
|
29
|
+
<div class="element_wrap">
|
30
|
+
<label>メールアドレス</label>
|
31
|
+
<p><?php echo $_POST['email']; ?></p>
|
32
|
+
</div>
|
33
|
+
<div class="element_wrap">
|
34
|
+
<label>性別</label>
|
35
|
+
<p><?php if( $_POST['gender'] === "male" ){ echo '男性'; }else{ echo '女性'; } ?></p>
|
36
|
+
</div>
|
37
|
+
<div class="element_wrap">
|
38
|
+
<label>年齢</label>
|
39
|
+
<p><?php if( $_POST['age'] === "1" ){ echo '〜19歳'; }
|
40
|
+
elseif( $_POST['age'] === "2" ){ echo '20歳〜29歳'; }
|
41
|
+
elseif( $_POST['age'] === "3" ){ echo '30歳〜39歳'; }
|
42
|
+
elseif( $_POST['age'] === "4" ){ echo '40歳〜49歳'; }
|
43
|
+
elseif( $_POST['age'] === "5" ){ echo '50歳〜59歳'; }
|
44
|
+
elseif( $_POST['age'] === "6" ){ echo '60歳〜'; } ?></p>
|
45
|
+
</div>
|
46
|
+
<div class="element_wrap">
|
47
|
+
<label>お問い合わせ内容</label>
|
48
|
+
<p><?php echo nl2br($_POST['contact']); ?></p>
|
49
|
+
</div>
|
50
|
+
<div class="element_wrap">
|
51
|
+
<label>プライバシーポリシーに同意する</label>
|
52
|
+
<p><?php if( $_POST['agreement'] === "1" ){ echo '同意する'; }else{ echo '同意しない'; } ?></p>
|
53
|
+
</div>
|
54
|
+
<input type="submit" name="btn_back" value="戻る">
|
55
|
+
<input type="submit" name="btn_submit" value="送信">
|
56
|
+
<input type="hidden" name="your_name" value="<?php echo $_POST['your_name']; ?>">
|
57
|
+
<input type="hidden" name="email" value="<?php echo $_POST['email']; ?>">
|
58
|
+
<input type="hidden" name="gender" value="<?php echo $_POST['gender']; ?>">
|
59
|
+
<input type="hidden" name="age" value="<?php echo $_POST['age']; ?>">
|
60
|
+
<input type="hidden" name="contact" value="<?php echo $_POST['contact']; ?>">
|
61
|
+
<input type="hidden" name="agreement" value="<?php echo $_POST['agreement']; ?>">
|
62
|
+
</form>
|
63
|
+
|
64
|
+
<?php elseif( $page_flag === 2 ): ?>
|
65
|
+
|
66
|
+
<p>送信が完了しました。</p>
|
67
|
+
|
68
|
+
<div id=home>
|
69
|
+
<p><a href="./index.html">ホームに戻る
|
70
|
+
</a></p>
|
71
|
+
</div>
|
72
|
+
<style type="text/css">
|
73
|
+
p {color: white;}
|
74
|
+
</style>
|
75
|
+
|
76
|
+
<?php else: ?>
|
77
|
+
|
78
|
+
<?php if( !empty($error) ): ?>
|
79
|
+
<ul class="error_list">
|
80
|
+
<?php foreach( $error as $value ): ?>
|
81
|
+
<li><?php echo $value; ?></li>
|
82
|
+
<?php endforeach; ?>
|
83
|
+
</ul>
|
84
|
+
<?php endif; ?>
|
85
|
+
|
86
|
+
<form method="post" action="">
|
87
|
+
<div class="element_wrap">
|
88
|
+
<label>氏名</label>
|
89
|
+
<input type="text" name="your_name" value="<?php if( !empty($_POST['your_name']) ){ echo $_POST['your_name']; } ?>">
|
90
|
+
</div>
|
91
|
+
<div class="element_wrap">
|
92
|
+
<label>メールアドレス</label>
|
93
|
+
<input type="text" name="email" value="<?php if( !empty($_POST['email']) ){ echo $_POST['email']; } ?>">
|
94
|
+
</div>
|
95
|
+
<div class="element_wrap">
|
96
|
+
<label>性別</label>
|
97
|
+
<label for="gender_male"><input id="gender_male" type="radio" name="gender" value="male" <?php if( !empty($_POST['gender']) && $_POST['gender'] === "male" ){ echo 'checked'; } ?>>男性</label>
|
98
|
+
<label for="gender_female"><input id="gender_female" type="radio" name="gender" value="female" <?php if( !empty($_POST['gender']) && $_POST['gender'] === "female" ){ echo 'checked'; } ?>>女性</label>
|
99
|
+
</div>
|
100
|
+
<div class="element_wrap">
|
101
|
+
<label>年齢</label>
|
102
|
+
<select name="age">
|
103
|
+
<option value="">選択してください</option>
|
104
|
+
<option value="1" <?php if( !empty($_POST['age']) && $_POST['age'] === "1" ){ echo 'selected'; } ?>>〜19歳</option>
|
105
|
+
<option value="2" <?php if( !empty($_POST['age']) && $_POST['age'] === "2" ){ echo 'selected'; } ?>>20歳〜29歳</option>
|
106
|
+
<option value="3" <?php if( !empty($_POST['age']) && $_POST['age'] === "3" ){ echo 'selected'; } ?>>30歳〜39歳</option>
|
107
|
+
<option value="4" <?php if( !empty($_POST['age']) && $_POST['age'] === "4" ){ echo 'selected'; } ?>>40歳〜49歳</option>
|
108
|
+
<option value="5" <?php if( !empty($_POST['age']) && $_POST['age'] === "5" ){ echo 'selected'; } ?>>50歳〜59歳</option>
|
109
|
+
<option value="6" <?php if( !empty($_POST['age']) && $_POST['age'] === "6" ){ echo 'selected'; } ?>>60歳〜</option>
|
110
|
+
</select>
|
111
|
+
</div>
|
112
|
+
<div class="element_wrap">
|
113
|
+
<label>お問い合わせ内容</label>
|
114
|
+
<textarea name="contact"><?php if( !empty($_POST['contact']) ){ echo $_POST['contact']; } ?></textarea>
|
115
|
+
</div>
|
116
|
+
<div class="element_wrap">
|
117
|
+
<label for="agreement"><input id="agreement" type="checkbox" name="agreement" value="1" <?php if( !empty($_POST['agreement']) && $_POST['agreement'] === "1" ){ echo 'checked'; } ?>>プライバシーポリシーに同意する</label>
|
118
|
+
</div>
|
119
|
+
<input type="submit" name="btn_confirm" value="入力内容を確認する">
|
120
|
+
</form>
|
121
|
+
</html>
|
122
|
+
|
123
|
+
<?php endif; ?>
|
124
|
+
```
|
13
125
|
```php
|
14
126
|
<?php
|
15
127
|
$name=filter_input(INPUT_POST,'your_name');
|