-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangepwd.php
More file actions
51 lines (45 loc) · 1.19 KB
/
changepwd.php
File metadata and controls
51 lines (45 loc) · 1.19 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
<html>
<body>
<?php
session_start();
print_r($_POST);
$link = mysqli_connect("localhost","root","","vtwa");
if(!$link)
die("Couldn't connect to DB");
if(isset($_SESSION['username']) && isset($_POST['oldpwd']))
{
$query = "select pwd from users where username = '".$_SESSION['username']."';";
$r = mysqli_query($link,$query);
$ra = mysqli_fetch_assoc($r);
if($_POST['oldpwd']==$ra['pwd'])
{
if($_POST['new0']==$_POST['new1'])
{
$q = "update users set pwd = '".$_POST['new0']."' where username = '".$_SESSION['username']."';";
$exec = mysqli_query($link,$q);
echo "<script>
alert('Password changed successfully');
window.location.replace('home.php');
</script>";
}
else{
echo "<script>
alert('New passwords do not match');
window.location.replace('home.php');
</script>";
}
}
else
echo "<script>
alert('Old password is incorrect');
window.location.replace('home.php');
</script>";
}
else
{
session_destroy();
header("location: home.php");
}
?>
</body>
</html>