forked from ngsankha/codejudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.php
61 lines (58 loc) · 2.3 KB
/
account.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
<?php
/*
* Codejudge
* Copyright 2012, Sankha Narayan Guria (sankha93@gmail.com)
* Licensed under MIT License.
*
* Account Settings page
*/
require_once('functions.php');
if(!loggedin())
header("Location: login.php");
else
include('header.php');
$link=connectdb();
?>
<li><a href="index.php">Problems</a></li>
<li><a href="submissions.php">Submissions</a></li>
<li><a href="scoreboard.php">Scoreboard</a></li>
<li class="active"><a href="#">Account</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<?php
if(isset($_GET['changed']))
echo("<div class=\"alert alert-success\">\nAccount settings updated!\n</div>");
else if(isset($_GET['passerror']))
echo("<div class=\"alert alert-error\">\nThe old password you entered is wrong. Please enter the correct password and try again.\n</div>");
else if(isset($_GET['derror']))
echo("<div class=\"alert alert-error\">\nPlease enter all the details asked before you can continue!\n</div>");
?>
Account settings for <?php echo($_SESSION['username']);?><hr/>
<form method="post" action="update.php">
<input type="hidden" name="action" value="password"/>
<h1><small>Change Password</small></h1>
Old password: <input type="password" name="oldpass"/><br/>
New password: <input type="password" name="newpass"/><br/><br/>
<input class="btn" type="submit" name="submit" value="Change Password"/>
</form>
<hr/>
<form method="post" action="update.php">
<input type="hidden" name="action" value="email"/>
<h1><small>Change Email</small></h1>
<?php
$query = "SELECT email FROM users WHERE username='".$_SESSION['username']."'";
$result = mysqli_query($link,$query);
$fields = mysqli_fetch_array($result,MYSQLI_BOTH);
?>
Email: <input type="email" name="email" value="<?php echo $fields['email'];?>"/><br/><br/>
<input class="btn" type="submit" name="submit" value="Change Email"/>
</form>
</div> <!-- /container -->
<?php
include('footer.php');
?>