-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchange_password.php
157 lines (106 loc) · 4.36 KB
/
change_password.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
include("header.php");
if (!isset($_SESSION["logged"])) {
$_SESSION["pleaselogin"] = True;
header("Location: .");
}
?>
<?php
if (isset($_POST["oldpass"])) {
#echo phpinfo();
$email = $_SESSION["logged"]["email"];
$oldpass = $_POST["oldpass"];
$newpass = $_POST["newpass"];
try {
$m = new MongoDB\Client("mongodb://vinay0410:[email protected]:23725/pizza");
$db = $m->pizza;
$collection = $db->users;
} catch(Exception $e) {
#die("Caught Exception failed to Connect".$e->getMessage()."\n");
$error_msg = "Couldn't Connect to Database";
$error = True;
}
if (empty($error)) {
$result = $collection->findOne(['email' => $email]);
#var_dump($result);
if ($result["password"] == $oldpass) {
//change password
$collection->updateOne(["email"=>$email], ['$set'=> ["password"=>$newpass]]);
$_SESSION["pop_profile"] = array("type" => "success", "msg" => "Password Updated Successfully");
header("Location: .");
} else {
$error = True;
$error_msg = "Current Password entered doesn't match";
}
}
}
?>
<script src="js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<div class="container pb-modalreglog-container">
<div class="row">
<div class="col-xs-12 col-md-4 col-md-offset-4">
<div class="form" >
<legend class="fp">Change Password</legend>
<fieldset>
<?php if(isset($error) AND $error) { ?>
<div id="error" class="alert alert-danger" role="alert"><?php echo $error_msg ?></div>
<?php } ?>
<form method="post" action="change_password.php" onsubmit="return pswd_match();">
<div class="form-group">
<label for="email">Current Password</label>
<div class="input-group pb-modalreglog-input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control" name="oldpass" id="oldpass" placeholder="Enter your Current Password">
</div>
</div>
<div class="form-group">
<label for="email">New Password</label>
<div class="input-group pb-modalreglog-input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control" name="newpass" id="pass" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="email">Confirm New Password</label>
<div class="input-group pb-modalreglog-input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control" name="confirmpass" id="confirmpass" placeholder="Confirm Password">
</div>
</div>
<input type="submit" class="btn btn-warning" name="submit" value="Update Password"/>
</form></fieldset>
</div>
</div></div></div>
<!-- end navigation -->
<!-- start flexslider -->
<!--<div class="flexslider">
<ul class="slides">
<li>
<img src="images/slider-img1.jpg" alt="Pizza Image 1">
<div class="flex-caption">
<h2 class="slider-title">We make Pizza</h2>
<h3 class="slider-subtitle">Fresh, clean, and delicious.</h3>
<p class="slider-description">Praesent tincidunt neque semper elementum gravida. Donec id euismod magna. Ut erat ligula, malesuada eu quam a, fringilla auctor augue.</p>
</div>
</li>
<li>
<img src="images/slider-img2.jpg" alt="Pizza Image 2">
<div class="flex-caption">
<h2 class="slider-title">Freshly Baked Pizza</h2>
<h3 class="slider-subtitle">Premium Quality, Finest Ingredients</h3>
<p class="slider-description">Donec id euismod magna. Ut erat ligula, malesuada eu quam a, fringilla auctor augue. Praesent tincidunt neque semper elementum gravida.</p>
</div>
</li>
</ul>
</div>-->
<!-- end flexslider -->
<!-- start about -->
<!-- end about -->
<!-- start gallery -->
<!-- end gallery -->
<!-- end contact -->
<!-- modals start -->
<?php include("modals.php"); ?>
<?php include("footer.php"); ?>