header("Location: loginSignUp.php"); exit; } $oCustomer = new User(); $oCustomer->load($_SESSION["UserID"]); $oCustomer->userID; $oSubmitForm = new Form(); if (isset($_POST["submit"])) { $oSubmitForm->data = $_POST; $oSubmitForm->files = $_FILES; //form validation $oSubmitForm->checkFilled("recipeTitle"); $oSubmitForm->checkFilled("authorNotes"); $oSubmitForm->checkFilled("ingredients"); $oSubmitForm->checkFilled("directions"); $oSubmitForm->checkFileUpload("imageUpload"); if ($oSubmitForm->valid == true) { $oRecipe = new Recipe(); //save details: $sImageName = "recipeImage-" . date("Y-m-d-H-i-s") . ".jpg"; $oSubmitForm->moveFile("imageUpload", $sImageName); $oRecipe->title = $_POST["recipeTitle"]; $oRecipe->authorNotes = $_POST["authorNotes"]; $oRecipe->ingredients = $_POST["ingredients"]; $oRecipe->directions = $_POST["directions"]; $oRecipe->imagePath = $sImageName; $oRecipe->userID = $oCustomer->userID; $oRecipe->recipeTypeID = $_POST["recipeCategory"]; $oRecipe->save(); header("Location: submitRecipe.php?message=submitted"); exit;
<?php require_once "includes/header.php"; require_once "includes/product.php"; require_once "includes/productManager.php"; require_once "includes/form.php"; $oProductForm = new Form(); if (isset($_POST["add"])) { $oProductForm->data = $_POST; $oProductForm->files = $_FILES; $oProductForm->checkFilled("productName"); $oProductForm->checkFilled("productDescription"); $oProductForm->checkFileUpload("imageUpload"); $oProductForm->checkFilled("productSize"); $oProductForm->checkFilled("productPrice"); $oProductForm->checkFilled("ingredients"); $oProductForm->checkFilled("stockLevel"); if ($oProductForm->valid == true) { $oProduct = new Product(); //save details: $sImageName = "productImage-" . date("Y-m-d-H-i-s") . ".jpg"; $oProductForm->moveFile("imageUpload", $sImageName); $oProduct->productName = $_POST["productName"]; $oProduct->description = $_POST["productDescription"]; $oProduct->imagePath = $sImageName; $oProduct->size = $_POST["productSize"]; $oProduct->price = $_POST["productPrice"]; $oProduct->ingredients = $_POST["ingredients"]; $oProduct->stockLevel = $_POST["stockLevel"]; $oProduct->save(); header("Location: addProduct.php?message=added");