-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
40 lines (33 loc) · 832 Bytes
/
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
38
39
40
<?php
include "sql.php";
include_once "controller.php";
function checkSignUpData($username, $password, $check_password) {
return
not_empty($username, $password, $check_password) &&
passwordsMatch($password, $check_password);
}
function passwordsMatch($password, $check_password) {
return $password === $check_password;
}
$username = post("username");
$password = post("password");
$check_password = post("check_password");
if(checkSignUpData($username, $password, $check_password)) {
$hash = md5($username . $password . time());
$user = get_user($username);
if (!$user) {
$user = get_new_user($username, $password);
$user_id = $user['id'];
set_session($hash, $user_id);
session_id($hash);
session_start();
session_commit();
redirect("/items");
}
else {
redirect("/");
}
}
else {
redirect("/");
}