-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_script.php
More file actions
26 lines (22 loc) · 874 Bytes
/
settings_script.php
File metadata and controls
26 lines (22 loc) · 874 Bytes
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
<?php
require 'common.php';
// check if logged in
if(!isset($_SESSION["email_id"])){
header("location: index.php");
}else{
// get user details
$user_id = $_SESSION["id"];
$email = $_SESSION["email_id"];
// get the newly typed password
$new_password = md5(mysqli_real_escape_string($conn, $_POST["new_pass"]));
$retype_pass = md5(mysqli_real_escape_string($conn, $_POST["retype_new_pass"]));
// check if the typed new passwords match
if($new_password != $retype_pass){
echo "The passwords do not match. Try again.";
}else{
$query = "UPDATE users SET password = '$new_password' WHERE email = '$email' AND id = '$user_id'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
header("location: settings.php");
}
}
?>