<?php 
include('../include/config.php');
$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
$timenow=$date->format('Y-m-d H:i:s');
$timenow2=$date->format('Y-m-d');
$month=$date->format('M');

if(!empty($_POST["id"]))
 {
 $id=$_POST["id"];
 $cpass=addslashes(md5($_POST["pass"]));
 $pass=addslashes(md5($_POST["npass"]));

$query=mysqli_query($con,"SELECT * FROM users WHERE userid='$id' AND Pass='$cpass'");
$num=mysqli_fetch_array($query);
if($num>0)
{

$sql2=mysqli_query($con,"UPDATE users SET Pass='$pass' WHERE userid='$id'");
if($sql2)
{
 $msg='changed your password.';
 $sql2=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month) VALUES('$id','$msg','$timenow','$timenow2','update','$month') ");   
echo "success";
}else
{
echo "Error in updating data";
}

}else
{
echo "No match";
}	
 }
?>