-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entry-output.php
63 lines (61 loc) · 2.19 KB
/
Entry-output.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
//var_dump($_REQUEST['email']);
$pdo=new PDO('mysql:host=mysql;charset=utf8','', '');
//$pdo=new PDO('mysql:host=localhost;dbname=shop;charset=utf8','staff', 'PASSWORD');
if (isset($_SESSION['customer'])) {
$id=$_SESSION['customer']['id'];
$sql=$pdo->prepare('select * from customer where id !=? and email=?');
$sql->execute([$id, $_REQUEST['email']]);
} else {
$sql=$pdo->prepare('select * from customer where email=?');
$sql->execute([$_REQUEST['email']]);
}
if (empty($sql->fetchAll())) {
if (isset($_SESSION['customer'])) {
$sql=$pdo->prepare('update customer set user=? and email=?, password=? where id=?');
$sql->execute([
$_REQUEST['user'], $_REQUEST['email'], $_REQUEST['password'], $id
]);
$_SESSION['customer']=[
'id'=>$id, 'user'=>$_REQUEST['user'],
'email'=>$_REQUEST['email'], 'password'=>$_REQUEST['password']
];
?>
<main class="text-center form-signin m-auto"><form>
<p>お客様情報を更新しました。</p></br>
<a href="login.php" class="w-100 btn btn-lg btn-primary">ログインしてください。</a>
<form></main>
<?php
} elseif (empty($_GET['user'] || empty($_GET['email'] || empty($_GET['password'])))){
?>
<main class="text-center form-signin m-auto"><form>
<p>登録できませんでした</p></br>
<form></main>
<?php
} else {
$sql=$pdo->prepare('insert into customer values(null,?,?,?)');
$sql->execute([
$_REQUEST['user'], $_REQUEST['email'], $_REQUEST['password']
]);
?>
<main class="text-center form-signin m-auto"></form>
<p>お客様情報を登録しました。</p></br>
<a href="login.php" class="w-100 btn btn-lg btn-primary">ログインしてください。</a>
</form></main>
<?php
//header('Location: member-index.php');
//exit;
}
} else {
echo 'メールアドレスが既に使用されています。';
}
?>
<?php require 'footer.php';?>