Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $entityBody = file_get_contents('php://input');
- $body = json_decode($entityBody,true);
- foreach ($body as $value)
- {
- $username = $value['username'];
- $oldPassword = $value['oldPassword'];
- $newPassword = $value['newPassword'];
- }
- $con = new MongoDBClient;
- if($con){
- $db = $con->users;
- // Select Collection
- $collection = $db->user;
- $filter = array(['Username' => $username,
- 'Password' => $oldPassword
- ]);
- $qry = new MongoDBDriverQuery($filter);
- $rows = $collection->findOne($qry);
- if($rows['Username']== $username && $rows['Password'] == $oldPassword)
- {
- $criteria = ['Username' => $rows['Username']];
- $newData = ['$set' => ['Password' => $newPassword]];
- $collection -> update($criteria,$newData);
- $changed = true;
- echo json_encode(array('status'=> '1','isChanged' => $changed));
- }
- else{
- $changed = false;
- echo json_encode(array('status'=> '2','isChanged' => $changed));
- }
- }
- else
- {
- die("Mongo DB not connected!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement