PHP Classes

File: uploady/admin/users/actions/update.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Uploady PHP Upload File to MySQL   uploady/admin/users/actions/update.php   Download  
File: uploady/admin/users/actions/update.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Uploady PHP Upload File to MySQL
Store file upload details in a MySQL database
Author: By
Last change: refactor
Code refactor
Date: 4 months ago
Size: 762 bytes
 

Contents

Class file image Download
<?php
require_once '../../session.php';

if (
$_SERVER['REQUEST_METHOD'] == "POST") {
   
$msg_code = "";

    if (!
$auth->checkToken($_POST['csrf'], $_SESSION['csrf'])) {
       
$utils->redirect($utils->siteUrl(
           
"/admin/users/view.php?&msg=csrf"
       
));
    }

    unset(
$_POST['csrf']);
   
$id = (int) $_POST['id'];

    if (!
$_POST['password'] || $_POST['password'] == "") {
        unset(
$_POST['password']);
    } else {
       
$password = $utils->sanitize($_POST['password']);
       
$_POST['password'] = password_hash($password, PASSWORD_BCRYPT);
    }

   
$msg_code = $user->update($id, $utils->esc($_POST)) ? "user_updated" : "error";

   
$utils->redirect($utils->siteUrl(
       
"/admin/users/view.php?&msg={$msg_code}"
   
));
}