-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdataRegist.php
More file actions
76 lines (60 loc) · 2.37 KB
/
dataRegist.php
File metadata and controls
76 lines (60 loc) · 2.37 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
<?php
// セッションの開始 session_start();
// 各入力データを取得
//$textName = $_SESSION["textName"];
//$textArea = htmlspecialchars($_SESSION["textArea"]);
//$textGenre = htmlspecialchars($_SESSION["textGenre"]);
//$textMessage = $_SESSION["textMessage"];
require_once('config.php');
require_once('./helpers/db_helper.php');
require_once('./helpers/extra_helper.php');
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$Restaurant_name = get_post('Restaurant_name');
$Restaurant_erea = get_post('Restaurant_erea');
$Restaurant_genre = get_post('Restaurant_genre');
$Restaurant_message = get_post('Restaurant_message');
$dbh = get_db_connect();
$errs = array();
//入力値のバリデーション
if (!check_words($Restaurant_name, 50)) {
$errs['Restaurant_name'] = 'お店の名前は必須、50文字以内です';
}
if (!check_words($Restaurant_erea, 50)) {
$errs['Restaurant_erea'] = 'お店のエリアは必須、50文字以内です';
}
if (!check_words($Restaurant_genre, 50)) {
$errs['Restaurant_genre'] = '料理のジャンルは必須、50文字以内です';
}
if (!check_words($Restaurant_message, 200)) {
$errs['Restaurant_message'] = '一言メッセージは必須、200文字以内です';
//echo "YES";
}
if (!empty($_SESSION['member'])) {
$member_id = $_SESSION['member']['id'];
//echo $member_id;
}
//エラーが無ければデータを挿入
if (empty($errs)) {
//echo "1";
if(insert_restaurant_data($dbh, $Restaurant_name, $Restaurant_erea, $Restaurant_genre, $Restaurant_message, $member_id)){
//echo "2";
header('Location: '.SITE_URL.'./formResult.php');
//echo "3";
exit;
}
//$errs['password'] = '登録に失敗しました。';
}
}
//include_once('../index.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"]); */
//登録完了後、入力画面へ遷移 header("Location: ./form.php");
?>