forked from ri-mo-mo-ri/17-pg-training
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_signup.php
37 lines (31 loc) · 972 Bytes
/
post_signup.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
<?php
require_once 'functions.php';
// ユーザー新規登録
$login_name = $_POST['login_name'];
$display_name = $_POST['display_name'];
// if ($_FILES['image']['name'] === '') {
// $image_file_name = '';
// } else {
// $image_file_name = md5(mt_rand()) . '.' . pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
// $upload_path = dirname(__FILE__) . '/image/' . $image_file_name;
// move_uploaded_file($_FILES['image']['tmp_name'], $upload_path);
// }
$database = getDatabase();
$user = $database->query("
SELECT *
FROM `user`
WHERE `login_name` = '{$login_name}'
")->fetch(PDO::FETCH_ASSOC);
if ($user === false) {
// 同じlogin_nameを持つユーザーがいなかったら新規登録
$database->query("
INSERT INTO `user` (
`login_name`,
`display_name`
) VALUES (
'{$login_name}',
'{$display_name}'
)
");
}
header('Location: /login.php');