itskp-odense/Backend/controller/updateUser.php

24 lines
452 B
PHP

<?php
session_start();
require "../../bootstrap.php";
use Backend\Model\User;
if(isset($_SESSION['permission'])){
$user = User::query()->find($_POST['id']);
if(!empty($_POST['upName'])){
$user->name = $_POST['upName'];
}
if(!empty($_POST['upPassword'])){
$newPass = password_hash($_POST['upPassword'], PASSWORD_DEFAULT);
$user->password = $newPass;
}
if($user->update()){
return 1;
}
}