-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathformCheck_sub.php
More file actions
56 lines (51 loc) · 1.79 KB
/
formCheck_sub.php
File metadata and controls
56 lines (51 loc) · 1.79 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
<?php
// セッションの開始
session_start();
//入力データを取得
// ニックネーム
$textName = $_POST["textName"];
// おすすめのカフェの名前
$textArea = $_POST["textArea"];
//おすすめのカフェのURL
$textGenre = $_POST["textGenre"];
// SNSを知らせるか選択
$textMessage = $_POST["textMessage"];
$isError = false;
// ニックネームの未入力チェック
if (empty($textName)) {
// 未入力の場合、エラーメッセージを格納
$_SESSION["errorName"] = "お店の名前が入力されていません";
$isError = true;
}
// おすすめのカフェの名前の未入力チェック
if (empty($textArea)) {
// 未入力の場合、エラーメッセージを格納
$_SESSION["errorArea"] = "お店のエリアが入力されていません";
$isError = true;
}
if (empty($textGenre)) {
// 未入力の場合、エラーメッセージを格納
$_SESSION["errorGenre"] = "料理のジャンルが入力されていません";
$isError = true;
}
// おすすめのカフェのURLの未入力チェック
if (empty($textMessage)) {
// 未入力の場合、エラーメッセージを格納
$_SESSION["errorMessage"] = "一言メッセージが入力されていません";
$isError = true;
}
// 入力データをセッションに登録
$_SESSION["textName"] = $textName;
$_SESSION["textArea"] = $textArea;
$_SESSION["textGenre"] = $textGenre;
$_SESSION["textMessage"] = $textMessage;
if ($isError) {
// エラーの場合、index.php に戻る
$_SESSION["formError"] = 1;
header("Location: ./index.php");
} else {
// エラーが無い場合、formConfirmation.php に戻る
header("Location: ./formConfirmation.php");
echo $isError;
}
?>