-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesti-submit.php
63 lines (50 loc) · 2.05 KB
/
desti-submit.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
56
57
58
59
60
61
62
63
<?php session_start();?>
<?php
if (isset($_SESSION['customer'])) {
require 'header_member.php';
}else{
require 'header_form.php';
}
?>
<?php
$pdo=new PDO('mysql:host=mysql;dbname=;charset=utf8','', '');
//$pdo=new PDO('mysql:host=localhost;dbname=shop;charset=utf8','staff', 'PASSWORD');
$info_entry = $pdo->query('SELECT * FROM info');//info
foreach($info_entry as $i_val) {
$cust_id = $i_val['cust_id'];
$ID = $i_val['addr_id'];
};
$zipcode = $_SESSION['zipcode'];
$pref = $_SESSION['pref'];
$addr1 = $_SESSION['addr1'];
$addr2 = $_SESSION['addr2'] ;
$cos_id = $_SESSION['customer']['id'];
if ($cos_id == $cust_id ){
$ad_sql = "UPDATE address SET zipcode=$zipcode, pref='$pref', addr1='$addr1', addr2='$addr2' where ID=$ID";
$ad_result = $pdo->prepare($ad_sql);
$ad_result->execute();
echo '<main class="text-center form-signin m-auto"><form>';
echo '<h3>お客様情報を</br>更新しました</h3></br>';
echo '<p>入力画面 -> 確認画面 -> <span class="badge bg-danger">完了画面</span></p></br>';
echo '<a href="mypage.php" class="btn btn-secondary">マイページへ</a>';
echo '</form></main>';
} else {
$ad_sql = "INSERT INTO address values (null,?, ?, ?, ?);";
$ad_result = $pdo->prepare($ad_sql); //address
$ad_result -> execute([
$zipcode,$pref,$addr1,$addr2
]);//address
$shn_id = $pdo->lastInsertId();
$e_sql = "INSERT INTO info values (null,?,?);";
$e_result = $pdo->prepare($e_sql); //info
$e_result -> execute([
$cos_id,$shn_id
]);//info
echo '<main class="text-center form-signin m-auto"><form>';
echo '<h3>登録が完了しました</h3></br>';
echo '<p>入力画面 -> 確認画面 -> <span class="badge bg-danger">完了画面</span></p></br>';
echo '<a href="mypage.php" class="btn btn-secondary">マイページへ</a>';
echo '</form></main>';
}
require 'footer.php';
?>