<?php
	session_start();
	include '../db/db.php';
	$response = array();
	if (isset($_POST['pwd'])) {
		/*echo $_POST['uname'];*/
		$user = htmlspecialchars(trim($_SESSION['user']), ENT_QUOTES, 'UTF-8');
		$pass = htmlspecialchars(trim($_POST['pwd']), ENT_QUOTES, 'UTF-8');
		
		$uname = strip_tags($user);
		$pwd = strip_tags($pass);

		$upass = hash('sha256', $pwd);

		$sql = mysqli_query($conn, "SELECT * FROM details_of_users WHERE user='$uname' and val=1");	
		$row = mysqli_fetch_assoc($sql);
		
		if(mysqli_num_rows($sql) == 1) {
			

			//echo $upass;

			$sql_up = mysqli_query($conn, "UPDATE details_of_users SET pass = '$upass' WHERE user='$uname' and val=1");
			
			echo 'Data inserted';
		}
		
		else{

			echo 'error';
			// wrong details
			//$response['message'] = '<span class="glyphicon glyphicon-info-sign"></span> &nbsp; Username or Password does not match.';
		}
		
		//echo "In";
	}
?>