-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdate-username.php
58 lines (34 loc) · 1.16 KB
/
Update-username.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
<?php
require 'connection.php';
if($_POST['Change'] == 'Change'){
if (is_string($_POST['username'])) {
$username = $_POST['username'];
$sql = "select username from user where username ='$username' ";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_assoc($result);
if($data){
if (trim($_POST['new_username'])) {
$new_username = $_POST['new_username'];
if ($data['username'] == $new_username){
echo 'new username is same as the old one!';
}else{
$sql = "update user set username='$new_username' where username = '$username'";
$result = mysqli_query($conn, $sql);
if ($result) {
echo 'Change successfully!';
}else{
echo 'Change unsuccessfully!';
}
}
}else{
echo "Please input new username!";
}
}else{
echo "Username does not exist!";
}
}else{
echo "Please input valid username!";
}
}
?>
?>