-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsignup.php
More file actions
43 lines (35 loc) · 1.35 KB
/
signup.php
File metadata and controls
43 lines (35 loc) · 1.35 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
<?php
require_once('config.php');
require_once('./helpers/db_helper.php');
require_once('./helpers/extra_helper.php');
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = get_post('name');
$email = get_post('email');
$password = get_post('password');
$dbh = get_db_connect();
$errs = array();
//入力値のバリデーション
if (!check_words($name, 50)) {
$errs['name'] = 'お名前欄は必須、50文字以内です';
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errs['email'] = 'メールアドレスの形式が正しくないです';
} elseif (email_exists($dbh, $email)) {
$errs['email'] = 'このメールアドレスは既に登録されています';
} elseif (!check_words($email, 100)) {
$errs['email'] = 'メールアドレスは必須、100文字以内です';
}
if (!check_words($password, 50)) {
$errs['password'] = 'パスワードは必須、50文字以内です';
}
//エラーが無ければデータを挿入
if (empty($errs)) {
if(insert_member_data($dbh, $name, $email, $password)){
header('Location: '.SITE_URL.'login.php');
exit;
}
$errs['password'] = '登録に失敗しました。';
}
}
include_once('./views/signup_view.php');