forked from khanhdnk/akathon01-23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewacc.php
52 lines (43 loc) · 1.51 KB
/
newacc.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
<?php
session_start();
include("./conn/func.php");
require_once("./functions/functions.php");
$data = getData("users");
$enable_regis = true;
// Get the submitted department number
$firstname = sanitise_input($_POST['fname']);
$lastname = sanitise_input($_POST['lname']);
$email = sanitise_input($_POST['email']);
$phone = sanitise_input($_POST['phone']);
$username = sanitise_input($_POST['username']);
$password = sanitise_input($_POST['password']);
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
$rdata = [
"id" => uuid(),
"admin" => false,
"email" => $email,
"firstname" => $firstname,
"lastname" => $lastname,
"order_time" => $timestamp,
"password" => $password,
"phone" => $phone,
"username" => $username
];
foreach ($data->data as $row) {
if(($row->username == $username)){
$enable_regis = false;
}
}
if($enable_regis == true){
$response = postData("users", $rdata);
echo $response;
$noti = "Sign up successful! Please login!";
// Encode the notification message for URL
$encodedNoti = urlencode($noti);
// Redirect to login.php with the notification message as a query parameter
header("Location: ./login.php?noti=$encodedNoti");
}else{
$errormsg = urlencode("Username has already been used");
header("Location: ./registration.php?noti=$errormsg");
}
?>