-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_profile.php
41 lines (37 loc) · 1.48 KB
/
update_profile.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
<?php
session_start();
include('database.inc.php');
include('function.inc.php');
include('constant.inc.php');
if(!isset($_SESSION['FOOD_USER_ID'])){
redirect(FRONT_SITE_PATH.'shop');
}
$uid = $_SESSION['FOOD_USER_ID'];
// include('smtp/PHPMailerAutoload.php');
// sleep(10);
// die();
$type = get_safe_value($_POST['type']);
if ($type == 'profile') {
$name = get_safe_value($_POST['name']);
$mobile = get_safe_value($_POST['mobile']);
$_SESSION['FOOD_USER_NAME']=$name;
mysqli_query($con, "update user set name='$name',mobile='$mobile' where id='$uid'");
$arr = array('status' => 'success', 'msg' => 'Profile has been updated');
echo json_encode($arr);
}
if ($type == 'password') {
$old_password = get_safe_value($_POST['old_password']);
$new_password = get_safe_value($_POST['new_password']);
$check = mysqli_num_rows(mysqli_query($con, "select * from user where password='$old_password'"));
$res = mysqli_query($con, "select password from user where id='$uid'");
$row = mysqli_fetch_assoc($res);
$dbpassword = $row['password'];
if (password_verify($old_password, $dbpassword)) {
$new_password = password_hash($new_password, PASSWORD_BCRYPT);
mysqli_query($con, "update user set password='$new_password' where id='$uid'");
$arr = array('status' => 'success', 'msg' => 'Password has been updated');
} else {
$arr = array('status' => 'error', 'msg' => 'Please enter correct password');
}
echo json_encode($arr);
}