-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_user.php
More file actions
73 lines (64 loc) · 1.62 KB
/
Copy pathsave_user.php
File metadata and controls
73 lines (64 loc) · 1.62 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
include 'functions.php';
require_once 'lib/passwordLib.php';
if($_SERVER['REQUEST_METHOD'] != 'POST'){
header('Location: index.php');
exit;
}
if(isset($_POST['login'])){
$login = $_POST['login'];
if($login == ''){
unset($login);
}
}
if(isset($_POST['password'])){
$password = $_POST['password'];
if($password ==''){
unset($password);
}
}
if(isset($_POST['mail'])){
$mail = $_POST['mail'];
if($mail ==''){
unset($mail);
}
}
if(empty($login) or empty($password) or empty($mail)){
header('Location: index.php?signup=empty_data');
exit;
}
reg_prepare($login);
reg_prepare($password);
reg_prepare($mail);
$db = connect();
if($db->connect_errno) {
header('Location: index.php?signup=db_error');
exit;
}
$ck_login = "SELECT 1 FROM `USERS` WHERE `Username` = '".$login."'";
$ck_mail = "SELECT 1 FROM `USERS` WHERE `Email` = '".$mail."'";
$ck_login_res = $db->query($ck_login);
$ck_mail_res = $db->query($ck_mail);
if(!$ck_login_res or !$ck_mail_res){
header('Location: index.php?signup=db_error');
exit;
}
if($ck_login_res->num_rows > 0){
header('Location: index.php?signup=login_exists');
exit;
}
if($ck_mail_res->num_rows > 0){
header('Location: index.php?signup=mail_exists');
exit;
}
$pass = password_hash($password, PASSWORD_DEFAULT);
$signup = "INSERT INTO `USERS`(`Username`, `Password`, `Email`) VALUES ('".$login."', '".$pass."', '".$mail."')";
$res = $db->query($signup);
if($res){
header('Location: index.php?signup=ok');
exit;
}else{
header('Location: index.php?signup=db_error');
exit;
}
?>