Example #1
0
<?php

require '../../include/global_functions.php';
loggedInOrRedirect();
$product_dao = new ProductDAO();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (file_exists($_FILES['image']['tmp_name']) && is_uploaded_file($_FILES['image']['tmp_name'])) {
        $image = base64_encode(file_get_contents($_FILES['image']['tmp_name']));
    } else {
        $image = '';
    }
    //update the product
    $product_dao->updateproduct($_GET['idproduct'], $_GET['idcategory'], $_GET['idspecification'], $_POST['serial_number'], $_POST['purchase_price'], $_POST['periodical_discount'], $_POST['brand'], $_POST['model'], $_POST['classification'], $_POST['cost'], $_POST['consumption'], $_POST['release_year'], $_POST['description'], $image);
    header('Location: manage_products.php?&idcategory=' . $_GET['idcategory'] . '&idspecification=' . $_GET['idspecification']);
}
//Select the product according to the id
$product = $product_dao->find($_GET['idproduct']);
$page['title'] = 'Modify product';
require '../../include/header.inc';
require '../../include/index.inc';
?>
<h3><?php 
echo t('Modify product');
?>
</h3>
<form class="form-horizontal" action = "?<?php 
echo 'idproduct=' . $_GET['idproduct'] . '&idcategory=' . $_GET['idcategory'] . '&idspecification=' . $_GET['idspecification'];
?>
" method="POST" enctype="multipart/form-data">

	<div class="form-group">