-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditUser.php
87 lines (74 loc) · 2.02 KB
/
editUser.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
78
79
80
81
82
83
84
85
86
87
<?php
session_start();
include 'database/connect.php';
include 'functions.php';
include 'langCheck.php';
protectAdmin();
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$activate = $_POST['activate'];
$id = $_POST['id'];
if(empty($username)){
echo $lang['usernameEmpty'];
exit();
}
if(empty($email)){
echo $lang['emailEmpty'];
exit();
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo $lang['emailInvalid'];
exit();
}
$query = $con->prepare("SELECT * FROM users WHERE username = ? AND username =
(SELECT username FROM users WHERE user_id = ?)");
$query->bind_param("ss", $username, $id);
$query->execute();
$query->store_result();
$res = $query->num_rows;
$query->close();
if($res === 0){
$query = $con->prepare("SELECT * FROM users WHERE username = ?");
$query->bind_param("s", $username);
$query->execute();
$query->store_result();
$nm = $query->num_rows;
$query->close();
if($nm > 0){
echo $lang['userExists'];
exit();
}
}
$query = $con->prepare("SELECT * FROM users WHERE email = ? AND email =
(SELECT email FROM users WHERE user_id = ?)");
$query->bind_param("ss", $email, $id);
$query->execute();
$query->store_result();
$res = $query->num_rows;
$query->close();
if($res === 0){
$query = $con->prepare("SELECT * FROM users WHERE email = ?");
$query->bind_param("s", $email);
$query->execute();
$query->store_result();
$nm = $query->num_rows;
$query->close();
if($nm > 0){
echo $lang['mailExists'];
exit();
}
}
if(!empty($password)){
$password = encrypt($password);
$query = $con->prepare("UPDATE users SET username = ?, email = ?, password = ?, active = ? WHERE user_id = ?");
$query->bind_param("sssss", $username, $email, $password, $activate, $id);
}
if(empty($password)){
$query = $con->prepare("UPDATE users SET username = ?, email = ?, active = ? WHERE user_id = ?");
$query->bind_param("ssss", $username, $email, $activate, $id);
}
$query->execute();
$query->close();
echo $lang['saved'];
?>