$data = $_POST;
if (isset($data['do_changes'])){
session_start();
$user = R::findOne('users', 'name = ?', array($_SESSION['logged_user']['name']));
$usr = R::load('users', $user->id);
if (!empty($data['new_name']) && $data['new_name'] != $usr->name) {
$usr->name = $data['new_name'];
}
R::store($usr);
}