-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-register.php
77 lines (63 loc) · 1.85 KB
/
data-register.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
include('dbconfig.php');
include('data-md5.php');
$output = array();
$acc_username = $_POST["acc_username"];
$acc_name = $_POST["acc_name"];
$acc_email = $_POST["acc_email"];
$acc_pass = $_POST["acc_pass"];
$acc_cpass = $_POST["acc_cpass"];
$acc_address = $_POST["acc_add"];
$acc_username = stripslashes($acc_username);
$acc_name =stripslashes($acc_name);
$acc_email = stripslashes($acc_email);
$acc_pass = stripslashes($acc_pass);
$acc_cpass = stripslashes($acc_cpass);
$acc_address = stripslashes($acc_address);
$acc_username = mysqli_real_escape_string($conn,$acc_username);
$acc_name = mysqli_real_escape_string($conn,$acc_name);
$acc_email =mysqli_real_escape_string($conn,$acc_email);
$acc_pass = mysqli_real_escape_string($conn,$acc_pass);
$acc_cpass = mysqli_real_escape_string($conn,$acc_cpass);
$acc_address = mysqli_real_escape_string($conn,$acc_address);
if ($acc_pass != $acc_cpass) {
$output['error'] = "Password not match";
}
else{
$newpass = encryptIt($acc_pass);
$sql = "SELECT * FROM `user` WHERE user_Name = '$acc_username'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$output['error'] = 'Username already used';
}
else {
$sql = "INSERT INTO `user` (
`user_ID`,
`lvl_ID`,
`user_img`,
`user_Fullname`,
`user_Name`,
`user_Pass`,
`user_Email`,
`user_Address`,
`user_Registered`)
VALUES (
NULL,
1,
NULL,
'$acc_name',
'$acc_username',
'$newpass',
'$acc_email',
'$acc_address',
CURRENT_TIMESTAMP);";
if ($result = mysqli_query($conn, $sql)) {
$output['success'] = 'Successfully Register';
}
else{
$output['error'] = 'Failed to Register';
}
}
}
echo json_encode($output,true);
?>