-
Notifications
You must be signed in to change notification settings - Fork 0
/
regist.php
49 lines (38 loc) · 1.27 KB
/
regist.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
<!DOCTYPE html>
<?php session_start(); ?>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$used = false;
$json = json_decode(file_get_contents("data.json"), true);
if (trim($_POST['name']) === '' || trim($_POST['email']) === '' || trim($_POST['password'] === '')){
echo "please fill the form";
echo'<a href="signup.php">重新填寫</a>';
}else{
if(array_key_exists($_POST['name'], $json) === true) {
echo "name has been used";
$used = true;
}
foreach ($json as $key => $value) {
if(in_array($_POST['email'], $json[$key]) === true){
echo "email has been used";
$used = true;
}
}
if ($used === false){
$_SESSION['registuser'] = $_POST['name'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
include 'mail.php';
} else{
echo'<a href="signup.php">重新填寫</a>';
}
}
?>
<a href="index.php">返回登入</a>
</body>
</html>