-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathChangeUsername.php
83 lines (71 loc) · 2.54 KB
/
ChangeUsername.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
<?php
include_once 'MenuBar.php';
include_once './AccountFiles/AccountDatabaseAPI.php';
if (!isset($_SESSION['userid'])) {
header('Location: ./MainMenu.php');
die();
}
// Check if the user is banned
if (isset($_SESSION["userid"]) && IsBanned($_SESSION["userid"])) {
header("Location: ./PlayerBanned.php");
exit;
}
?>
<?php
include_once 'Header.php';
?>
<div class="core-wrapper">
<div class="flex-padder"></div>
<div class="flex-wrapper">
<div class='container bg-black'>
<section class="change-username-form">
<h2>Change Your Username</h2>
<div class="change-username-form-form">
<form action="includes/change-username.inc.php" method="post">
<label for="uid">Username</label>
<input type="text" disabled name="uid" value="<?php echo $_SESSION['useruid'] ?>">
<input type="hidden" name="uid" value="<?php echo $_SESSION['useruid']; ?>">
<label for="newuid">New Username</label>
<input type="text" name="newuid">
<label for="confirmnewuid">Confirm New Username</label>
<input type="text" name="confirmnewuid">
<div style="text-align:center;">
<button type="submit" name="submit">Change</button>
</div>
</form>
</div>
<?php
// Error messages
if (isset($_GET["error"])) {
if ($_GET["error"] == "emptyinput") {
echo "<h3 class='changer-username-error-message'>Fill in all fields!</h3>";
} else if ($_GET["error"] == "invaliduid") {
echo "<h3 class='changer-username-error-message'>Choose a username without any special characters</h3>";
} else if ($_GET["error"] == "usernamesdontmatch") {
echo "<h3 class='changer-username-error-message'>Usernames doesn't match!</h3>";
} else if ($_GET["error"] == "stmtfailed") {
echo "<h3 class='changer-username-error-message'>Something went wrong!</h3>";
} else if ($_GET["error"] == "usernametaken") {
echo "<h3 class='changer-username-error-message'>Username already taken!</h3>";
} else if ($_GET["error"] == "none") {
echo "<h3 class='changer-username-error-message'>Your username have changed!</h3>";
}
}
?>
</section>
</div>
</div>
<div class="flex-padder"></div>
</div>
<script>
function showPopupAndRedirect() {
alert("Your username has been successfully changed! Please log in with your new username.");
window.location.href = "./AccountFiles/LogoutUser.php?redirect=login";
}
<?php if (isset($_GET["error"]) && $_GET["error"] == "none") { ?>
window.onload = showPopupAndRedirect;
<?php } ?>
</script>
<?php
include_once 'Disclaimer.php';
?>