PHP Classes

File: uploady/profile/actions/update.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Uploady PHP Upload File to MySQL   uploady/profile/actions/update.php   Download  
File: uploady/profile/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: Fixea
Date: 3 months ago
Size: 1,117 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']) == false) {
       
$msg_code = "csrf";
    } else {
       
$user_array = [];
       
$current_id = (int) $data->id;
       
$id = (int) $_POST['id'];
        if (
$id == $current_id) {
           
$user_array['username'] = $utils->sanitize($_POST['username']);
           
$user_array['email'] = $utils->sanitize($_POST['email']);

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

            if (
$user->update($id, $user_array)) {
               
$_SESSION['username'] = $user_array['username'];
               
$msg_code = "profile_updated";
            } else {
               
$msg_code = "error";
            }
        } else {
           
$msg_code = "attack";
        }
    }

   
$utils->redirect($utils->siteUrl("/profile/account.php?msg=" . $msg_code));
}