-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathform_sub.php
More file actions
105 lines (98 loc) · 3.39 KB
/
form_sub.php
File metadata and controls
105 lines (98 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// セッションの開始
session_start();
// 入力フォーム用セッションの初期化
if (!isset($_SESSION["textName"])) {
$_SESSION["textName"] = "";
}
if (!isset($_SESSION["textArea"])) {
$_SESSION["textArea"] = "";
}
if (!isset($_SESSION["textGenre"])) {
$_SESSION["textGenre"] = "";
}
if (!isset($_SESSION["textMessage"])) {
$_SESSION["textMessage"] = "";
}
if (!isset($_SESSION["errorName"])) {
$_SESSION["errorName"] = "";
}
if (!isset($_SESSION["errorArea"])) {
$_SESSION["errorArea"] = "";
}
if (!isset($_SESSION["errorGenre"])) {
$_SESSION["errorGenre"] = "";
}
if (!isset($_SESSION["errorMessage"])) {
$_SESSION["errorMessage"] = "";
} ?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>HTML+CSS トレーニング</title>
</head>
<body>
<div class="container">
<div class="contentheader">今回のお題
</div>
<div class="contentbody"> 「はこだてのおすすめのカフェ」
</div>
<div class="contentfooter"> 投稿する
</div>
</div>
<h2>入力フォーム</h2>
<!-- 入力フォームをまとめる form タグ(method:データの送信方法、action:フォーム の送信先ページ) -->
<form method="GET" action="./dataRegist.php" id="inputForm">
<!-- ニックネーム入力-->
<p>1. お店の名前</p>
<input type="text" name="textName" value="<?php echo $_SESSION["textName"]; ?>">
<?php
// 未入力チェックでエラーの場合は、エラーメッセージを表示
if (!empty($_SESSION["errorName"])) {
echo "<div class=\"errorMessage\">" . $_SESSION["errorName"] . "</div>";
}
?>
<!-- 項目選択(form:この選択肢に対応するフォームタグの id) -->
<p>2. お店のエリア</p>
<input type="text" name="textArea" value="<?php echo $_SESSION["textArea"]; ?>">
<?php
// 未入力チェックでエラーの場合は、エラーメッセージを表示
if (!empty($_SESSION["errorArea"])) {
echo "<div class=\"errorMessage\">" . $_SESSION["errorArea"] . "</div>";
}
?>
<p>3. 料理のジャンル</p>
<input type="text" name="textGenre" value="<?php echo $_SESSION["textGenre"]; ?>">
<?php
// 未入力チェックでエラーの場合は、エラーメッセージを表示
if (!empty($_SESSION["errorGenre"])) {
echo "<div class=\"errorMessage\">" . $_SESSION["errorGenre"] . "</div>";
}
?>
<p>3. 一言メッセージ</p>
<input type="text" name="textMessage" value="<?php echo $_SESSION["textMessage"]; ?>">
<?php
// 未入力チェックでエラーの場合は、エラーメッセージを表示
if (!empty($_SESSION["errorMessage"])) {
echo "<div class=\"errorMessage\">" . $_SESSION["errorMessage"] . "</div>";
}
?>
<!-- 送信ボタン -->
<p><input type="submit"></p>
</form>
<button onclick="location.href='./views/signup_view.php'">新規登録</button>
<button onclick="location.href='./views/login_view.php'">ログイン</button>
</body>
</html>
<?php
// 入力チェック結果を出力後に、セッションを削除
unset($_SESSION["textName"]);
unset($_SESSION["textArea"]);
unset($_SESSION["textGenre"]);
unset($_SESSION["textMessage"]);
unset($_SESSION["errorName"]);
unset($_SESSION["errorArea"]);
unset($_SESSION["errorGenre"]);
unset($_SESSION["errorMessage"]);
?>