Example #1
0
<?php

require_once __DIR__ . "/../../_includes/initialize.php";
// Get product with the id that matches from the database
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $item = Item::find_by_id($id);
} else {
    $item = new Item();
    $item->set_category('Krukväxter');
}
if (isset($_POST['submit'])) {
    $item->name = $_POST['name'];
    $item->set_category($_POST['category']);
    $item->price = $_POST['price'];
    $item->set_sub_cat($_POST['sub_cat']);
    if (isset($_POST['active'])) {
        $item->active = $_POST['active'];
    } else {
        $item->active = 0;
    }
    $item->save();
}
include_once LAYOUT_PATH . "header.php";
?>

<form action="manageproduct.php?id=<?php 
echo $id;
?>
" method="POST">
	<table>