-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddMerchant.php
More file actions
56 lines (41 loc) · 1.44 KB
/
addMerchant.php
File metadata and controls
56 lines (41 loc) · 1.44 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
<?php
include 'DatabaseConfig.php';
include 'helper_functions/authentication_functions.php';
// Creating MySQL Connection.
if (isset($_POST['username']) && isset($_POST['password']) && isset($_FILES['image']) ) {
$username = $_POST['username'];
$password = $_POST['password'];
$image = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
$image_size = $_FILES['image']['size'];
$image_ext = pathinfo($image, PATHINFO_EXTENSION);
$image_path = "images/".$image;
//check if the username is already in the database
$check_name = "SELECT * FROM users WHERE username = '$username'";
$result = mysqli_query($con, $check_name);
$count = mysqli_num_rows($result);
if ($count > 0) {
echo json_encode(
[
'success' => false,
'message' => 'username already exists'
]
);
} else {
// $sql1 = "select User_Id from users where username='$username'";
// $query1 = mysqli_query($con, $sql1);
// if ($query1) {
// $data1 = '';
// while ($row1 = mysqli_fetch_assoc($query1)) {
// $data1 = $row1['User_Id'];
// }
addMerchant($username, $password, $image, $image_tmp, $image_size, $image_ext, $image_path);
}
} else {
echo json_encode(
[
'message' => 'Please fill all the fields.',
'success' => false
]
);
}