-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_script.php
More file actions
51 lines (41 loc) · 1.61 KB
/
Copy pathsettings_script.php
File metadata and controls
51 lines (41 loc) · 1.61 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
<?php
error_reporting(0);
$con = mysqli_connect('localhost','id11590341_rajat','Rajat@123','id11590341_mydb');
session_start();
if (!isset($_SESSION['email'])) {
header('location: index.php');
}
// This page updates the user password
$old_pass = $_POST['old-password'];
//$old_pass = mysqli_real_escape_string($con, $old_pass);
//$old_pass = MD5($old_pass);
$new_pass = $_POST['password'];
//$new_pass = mysqli_real_escape_string($con, $new_pass);
//$new_pass = MD5($new_pass);
$new_pass1 = $_POST['password1'];
//$new_pass1 = mysqli_real_escape_string($con, $new_pass1);
//$new_pass1 = MD5($new_pass1);
$query = "SELECT email, password FROM tbl_employee WHERE email ='" . $_SESSION['email'] . "'";
$result = mysqli_query($con, $query)or die($mysqli_error($con));
$row = mysqli_fetch_array($result);
$orig_pass = $row['password'];
if ($new_pass != $new_pass1) {
header('location: setting.php?error=The two passwords don\'t match');
} else {
if ($old_pass == $orig_pass) {
$query = "UPDATE tbl_employee SET password = '" . $new_pass . "' WHERE email = '" . $_SESSION['email'] . "'";
$data= mysqli_query($con, $query) or die($mysqli_error($con));
if($data)
{
echo '<script language="javascript">';
echo 'alert("Password is successfully changed")';
echo '</script>';
?>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL= http://localhost/My/index2.php">
<?php
}
//header('location: setting.php?error=Password changed');
} else
header('location: setting.php?error=Wrong Old Password');
}
?>