forked from kulten/website-for-arduino-based-energy-meter
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusersettings.php
More file actions
122 lines (106 loc) · 3.3 KB
/
usersettings.php
File metadata and controls
122 lines (106 loc) · 3.3 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
.city{
float:left;
margin: 10px;
padding: 10px;
width: 50px;
height: 50px;
border: 1px solid black;
}
</style>
</head>
<link rel="stylesheet" type="text/css" href="main.css">
<body>
<div align = "right" class="container" style="background-color:#777">
<input type ="button" class ="button" value ="search" onclick="location='resultspage.php'">
<input type ="button" class ="button" value ="logout" onclick="location='logout.php'">
</div>
<form method="post"> <br> <br> <br>
<center>
<div>
<table>
<tr>
<td>
<label>Username</label>
</td>
<td>
<span><?php echo $_SESSION['login_user'];?></span>
</td>
</tr>
<tr>
<td>
<label>Old password</label>
</td>
<td>
<input type = "password" name ="password" value = "" id="oPass"required>
</td>
</tr>
<tr>
<td>
<label>New password</label>
</td>
<td>
<input type = "password" name = "password" value = "" id="nPass"required>
</td>
</tr>
<tr>
<td>
<label>Verify new password</label>
</td>
<td>
<input type = "password" name = "Password" value = "" id="vPass"required>
</td>
</tr>
<tr>
<td>
<label>City </label>
</td>
<td>
<input type = "text" name = "City" id="city" value = <?php echo $_SESSION['city']?> required>
</td>
</tr>
<tr>
<td>
<label>State</label>
</td>
<td>
<input type = "text" name = "State" id="state" value = <?php echo $_SESSION['state']?> required>
</td>
</tr>
</table>
<button onclick="validateSettings()" class="button"> submit </button><br><br>
<input type="button" class="button" value="change Interests" onclick="location='selectInterest.php'">
</div>
</center>
</form>
<script type="text/javascript">
function validateSettings()
{
var oldpass, newPass, verPass,city, state;
oldpass = document.getElementById("oPass").value;
newPass = document.getElementById("nPass").value;
verPass = document.getElementById("vPass").value;
city=document.getElementById("city").value;
state=document.getElementById("state").value;
var elements = [oldpass, newPass, verPass,city,state];
var httpc = new XMLHttpRequest(); // simplified for clarity
var url = "changeUSettings.php?elements=";
httpc.open("POST", url+elements, true); // sending as POST
httpc.onreadystatechange = function() { //Call a function when the state changes.
if(httpc.readyState == 4 && httpc.status == 200) { // complete and no errors
alert(httpc.responseText); // some processing here, or whatever you want to do with the response
}
}
httpc.send(elements);
}
</script>
</body>
</html>