-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmitChangedInfo.html
68 lines (55 loc) · 2 KB
/
submitChangedInfo.html
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
<!--this is where we should use firebase connection-->
<!--<?php
//session_start();
?>-->
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAKAvtSqE25LzqCWv4PzPlHuC9a-UadF7U",
authDomain: "studyswapwebsite.firebaseapp.com",
databaseURL: "https://studyswapwebsite.firebaseio.com",
projectId: "studyswapwebsite",
storageBucket: "studyswapwebsite.appspot.com",
messagingSenderId: "271728404472"
};
firebase.initializeApp(config);
</script>
<?php
session_start();
//Address error handling
ini_set('display_errors', 1);
//error_reporting(E_ALL & E_NOTICE);
//Attempt to connect
if($connection=@mysql_connect('localhost', 'tshay1', 'DHS23Hornets')){
//print '<p>Successfully connected to MySQL.</p>';
}else{
die('<p>Could not connect to MySQL because:<b>'.mysql_error().'</b></p>');
}
if(@mysql_select_db("tshay1DB", $connection)){
//print '<p> The tshay1DB database has been selected</p>';
}else{
die('<p>Could not select the tshay1DB database because:<b>'.mysql_error().'</b></p>');
}
$changedEmail=$_POST['email'];
$changedPassword=$_POST['password'];
$usernameOfUser=$_SESSION['username'];
$getIDofUser = "SELECT id FROM users WHERE username='$usernameOfUser'";
$IDresults=mysql_query($getIDofUser);
if (!$IDresults)
{ // add this check.
die('Invalid query: ' . mysql_error());
}
$IDrow=mysql_fetch_array($IDresults);
$userID=$IDrow['id'];
$updateUserInfo="UPDATE `users` SET `email`='$changedEmail', `password`='$changedPassword' WHERE id='$userID'";
$updateResults=mysql_query($updateUserInfo);
if (!$updateResults)
{ // add this check.
die('Invalid query: ' . mysql_error());
}
else
{
echo 'You have successfully changed your info. <a href="editUserInfo.html">Go back</a>';
}
?>