-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinish.php
55 lines (46 loc) · 1.34 KB
/
finish.php
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
<?php
require_once('DB_connection.php');
require_once('prefecture_data.php');
function sendPOST2DB($post_data) {
$dsn = 'mysql:dbname=firstDB;host=127.0.0.1';
$user = 'root';
$db_connection = DB_Connection::getInstance($dsn,$user);
$pdo = $db_connection->getPDO();
//登録
try {
sendDBModule($pdo, $post_data);
} catch (PDOException $e) {
print('Add failed:'.$e->getMessage());
var_dump($e->getMessage());
}
}
function sendDBModule($pdo, $post_data) {
$query = $pdo->prepare("
INSERT INTO account_info(
first_name,
last_name,
email,
pref_id,
created_at,
updated_at
) VALUES (
:first_name,
:last_name,
:email,
:pref_id,
NOW(),
NOW()
)
");
$first_name = $post_data['name_first'];
$last_name = $post_data['name_last'];
$email = $post_data['mail_address'];
$pref_id = Prefecture_Data::getPrefectureID($post_data['prefecture']);
$query->bindParam(':first_name', $first_name);
$query->bindParam(':last_name' , $last_name);
$query->bindParam(':email' , $email);
$query->bindParam(':pref_id' , $pref_id);
$result = $query->execute();
}
sendPOST2DB($_POST);
include('finish.html.php');