forked from miyurusankalpa/driver-booking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_admin_process.php
More file actions
executable file
·77 lines (57 loc) · 2.16 KB
/
Copy pathnew_admin_process.php
File metadata and controls
executable file
·77 lines (57 loc) · 2.16 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
74
75
76
77
<?php //inception
header('Content-Type: application/json');
include_once 'mysqli.php';
$error = array(); $array = array();
// connecting to database
$sql = new mysqli($server, $user, $pass, $db);
if (isset($_POST['register'])) {
$Firstname = mysqli_real_escape_string($sql, $_POST['Firstname']);
$Lastname = mysqli_real_escape_string($sql, $_POST['Lastname']);
$username = mysqli_real_escape_string($sql, $_POST['username']);
$email = mysqli_real_escape_string($sql, $_POST['Email']);
$password = mysqli_real_escape_string($sql, $_POST['password']);
$conpassword = mysqli_real_escape_string($sql, $_POST['Conpassword']);
$mobileNo = mysqli_real_escape_string($sql, $_POST['mobileNo']);
//print_r($_POST);
if(empty($Firstname)) {
array_push($error, "Firstname is required");
}
if(empty($Lastname)) {
array_push($error, "Lastname is required");
}
if(empty($username) ) {
array_push($error, "Username is required"); //error msg username
}
if(empty($email)) {
array_push($error, "Email is required"); //error msg password
}
if(empty($password)) {
array_push($error, "Password is required");
}
if(empty($conpassword)) {
array_push($error, "Confirm password is required");
}
if($password != $conpassword) {
array_push($error, "Confim passwords do not match. Try again");
}
if(count($error) == 0) {
$encryptpass = md5($password); //encryption
$query = "INSERT INTO users (`firstname`, `lastname`, `username`, `email`, `password`, `mobileno`, `group`) VALUES ('$Firstname', '$Lastname', '$username', '$email', '$encryptpass', '$mobileNo','Admin')";
$x = mysqli_query($sql, $query);
if($x)
{
$array["result"] = "success";
$array["message"] = "New Administrator Registration Successful.";
goto output;
} else {
//echo mysqli_error($sql);
array_push($error, "Error adding date to the database. Try again");
}
}
} else array_push($error, "Empty Data.");
$array["result"] = "error";
$array["message"] = $error;
output:
$json = json_encode($array);
echo $json;
?>