-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchngpass.php
More file actions
70 lines (62 loc) · 2 KB
/
chngpass.php
File metadata and controls
70 lines (62 loc) · 2 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
<?php
$q=$_GET["user"];
?>
<?php
$link=mysqli_connect("localhost","root","");
mysqli_select_db($link,"chatapp");
?>
<?php
if(isset($_POST["submit"])){
$prvpass=md5($_POST["pass"]);
$new=md5($_POST["newpass"]);
$res=mysqli_query($link,'SELECT * FROM login_table WHERE id="'.$q.'"');
while($row=mysqli_fetch_array($res))
{
if($prvpass==$row["password"]){
$result=mysqli_query($link,'UPDATE login_table SET password="'.$new.'" WHERE id="'.$q.'"');
}
else{
?>
<script>
window.alert("Password is incorrect");
</script>
<?php
}
}
}
?>
<?php
include "headerchngpass.php";
?>
<nav>
<?php
$result=mysqli_query($link,'SELECT profilepic FROM profile_pic WHERE id="'.$q.'"');
while($row=mysqli_fetch_assoc($result)){
if ($row["profilepic"] == ""){
echo '<a href="profilepic.php?user='.$q.'" class="img-blur"><img class="img-circle" src="profilepicture/default.jpg" alt="default DP" style="float: left"></a>';
}else{
echo "<a href='profilepic.php?user=".$q."' class='img-blur'><img class='img-circle' src='profilepicture/".$row['profilepic']."' alt='DP'style='float: left'></a>";
}
}
?>
<?php
$res=mysqli_query($link,'SELECT * FROM login_table WHERE id="'.$q.'"');
while($row=mysqli_fetch_array($res)){
?>
<form method="post" style="float: right; padding-right: 400px;" action="">
<h1><?php echo $row["username"] ?></h1><br>
Previous Password:<span style="padding-left: 20px;">
<input type="password" name="pass" value="" required></input><br></span><br><br>
New Password:<span style="padding-left: 54px;">
<input type="password" name="newpass" value="" pattern="[A-Za-z0-9].{7,}" title="Please enter password in [a-z and 0-9] format and min of 7 digits" required></input><br></span><br><br>
<span style="padding-left: 184px;">
<input type="submit" value="Change password" name="submit"></input></span>
<a href="userprofile.php?user=<?php echo $row["id"] ?>" style="text-decoration: none;">
<input type="button" value="Previous Page" name="change"></input></span></a>
</nav>
<?php
}
?>
<?php
include "footer.php";
?>