-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
116 lines (114 loc) · 5.24 KB
/
Copy pathprofile.php
File metadata and controls
116 lines (114 loc) · 5.24 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
<?php
include('dbconfig.php');
if(!$dbfun->is_logged_in()){ header('Location: login.php'); }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="pl">
<head>
<meta charset="utf-8">
<title>Drawing Tasks System</title>
<meta name="Marek Kozłowski">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="js/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
$('#changePassword-form').each(function(){
$(this).validate({
rules: {
oldpassword: {required:true},
newpassword: {required:true, minlength: 5},
confirmpassword: {required:true, minlength: 5, equalTo: '#newpassword'}
},
messages: {
oldpassword: {required: 'Musisz podać dotychczasowe hasło'},
newpassword: {required: 'Musisz podać nowe hasło', minlength: 'Hasło musi zawierać min 5 znaków'},
confirmpassword: {required: 'Musisz powtórzyć nowe hasło', minlength: 'Hasło musi zawierać min 5 znaków', equalTo: 'Hasła nie są identyczne'}
},
errorElement: 'div',
errorLabelContainer: '.errorpass'
});
});
});
$(document).ready(function(){
$('#changeEmail-form').each(function(){
$(this).validate({
rules: {
changedEmail: {required: true, email: true}
},
messages: {
changedEmail: {required: 'Musisz podać adres email', email: 'Podaj właściwy adres email'}
},
errorElement: 'div',
errorLabelContainer: '.erroremail'
});
});
});
</script>
<style type="text/css">
body { background: url(assets/bglight.png);}
.hero-unit { background-color: #fff; }
.center { display: block; margin: 0 auto; }
.navbar-fixed-bottom {background-color: #f5f5f5; }
</style>
</head>
<body>
<?php
if($dbfun->isadmin($_SESSION['key']) == 1){
include_once("ui/logged_navtop_admin.htm");
}else {
include_once("ui/logged_navtop.htm");
}
$result = $dbfun->getUserDetails($_SESSION['key']);
?>
<div class="container hero-unit">
<h3><?php echo ($result['firstname'].' '.$result['lastname']); ?></h3>
<hr>
<h4>Zmień email</h4>
<?php if(!isset($_POST['changeEmailbtn'])){ ?>
<form id="changeEmail-form" role="form" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" >
<div class="form-group">
<input type="text" name="changedEmail" id="changedEmail" placeholder="Adres email" value="<?php echo $_SESSION['key'];?>">
</div>
<button type="submit" name="changeEmailbtn" class="btn btn-default">Zmień</button>
<br><br>
<div class="erroremail"></div>
</form>
<?php
} else {
$dbfun->changeEmail($_POST['changedEmail']);
$dbfun = null;
}
?>
<hr>
<h4>Zmień hasło</h4>
<?php if(!isset($_POST['changePassword'])){ ?>
<form id="changePassword-form" role="form" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-lock"></span>
<input type="password" name="oldpassword" id="oldpassword" class="form-control" placeholder="Stare hasło">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-lock"></span>
<input type="password" name="newpassword" id="newpassword" class="form-control" placeholder="Nowe hasło">
<input type="password" name="confirmpassword" id="confirmpassword" class="form-control" placeholder="Potwierdź hasło">
</div>
</div>
<button type="submit" name="changePassword" class="btn btn-default">Zmień</button>
<br><br>
<div class="errorpass"></div>
</form>
<?php
} else {
$dbfun->changePassword($_SESSION['key'], $_POST['oldpassword'], password_hash($_POST['confirmpassword'], PASSWORD_DEFAULT));
$dbfun = null;
}
?>
</div>
<?php include("ui/footer.htm"); ?>
</body>
</html>