itskp-odense/Backend/controller/updateUser.php

24 lines
425 B
PHP

<?php
require "../../bootstrap.php";
use Backend\Model\User;
if(isset($_POST['id'])){
$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;
}
}