-
Notifications
You must be signed in to change notification settings - Fork 2
/
fp4.php
59 lines (48 loc) · 1.38 KB
/
fp4.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
<html>
<head>
<title>fp4</title>
<?php
session_start();
if ( isset( $_SESSION['user_id'] ) ) {
$idh=$_SESSION['user_id'];
echo $idh.'dfdsfs';
} else {
echo 'Password can\'t be changed. session expired.';
header("Refresh:2; URL=login.php");
die();
}
function error(){
echo"<script type='text/javascript'> alert('passwords don\'t match!!');window.location.replace('changePass.php');</script>";
die();
}
function success(){
session_unset();
session_destroy();
echo"<script type='text/javascript'> alert('password changed successfully!!');window.location.replace('logout.php');</script>";
die();
}
function error2(){
echo"<script type='text/javascript'> alert('password change unsuccessful!!');window.location.replace('changePass.php');</script>";
die();
}
?>
</head>
<body>
<?php
include 'connection.php';
$pas1=$_POST['pas1'];
$pas2=$_POST['pas2'];
if(strcmp($pas1,$pas2)==0)
{
$sql = "UPDATE `login` SET `password`='$pas2' where username='$idh'";
$result = $conn->query($sql);
if($result){success();}
else{error2();}
}
else{
error();
}
$conn->close();
?>
</body>
</html>