-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathusernameChange.php
More file actions
90 lines (70 loc) · 2.72 KB
/
usernameChange.php
File metadata and controls
90 lines (70 loc) · 2.72 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
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
session_start();
include 'loginFunctions.php';
if(isset($_POST['guestBtn'])){
$_SESSION['loggedIn'] = "No";
header('Location: home.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Scoot</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<header>
<div class="top">
<img src="images/scoot.png" id="logo" onclick="window.location.href='home.php'" style="cursor:pointer">
</div>
</header>
<nav id="nav">
<a style='margin-right:200px'href='profile.php'> My Profile </a>
<a href='logout.php'> Logout </a>
</nav>
<div class="center">
<h3>Change Username</h3>
<form method="POST" class="login">
<input type="text" name="newUsername" id ="newUsername" placeholder="New Username"></input>
<input type="password" name="password" id="password" placeholder="Password"></input><span id="Invalid"></span>
<button type="button" id="submitBtn" value="change">Change</button>
</form>
</div>
<div class="error">
</div>
</body>
</html>
<script>
$("#submitBtn").click(onButtonClicked);
function onButtonClicked() {
var jsonData = {
"newUsername": $("#newUsername").val(),
"password" : $("#password").val()
};
$.ajax({
// The URL for the request
url: "settingsFunctions.php",
// Whether this is a POST or GET request
type: "POST",
// The type of data we expect back
dataType: "json",
contentType: "application/json",
data: JSON.stringify(jsonData),
})
.done(function(data) {
if(data["data"] == "true"){
$(".error").empty();
$(".center").empty();
$(".center").html("<h2>Username Changed</h2>");
}
else{
$(".error").empty();
$(".error").append("<h2>" + data["data"] + "</h2>");
}
})
.always(function(data, status) {
});
}
</script>