$oRecipe = new Recipe(); $oRecipe->load($iRecipeID); $aExistingData = array(); $aExistingData["recipeTitle"] = $oRecipe->title; $aExistingData["authorNotes"] = $oRecipe->authorNotes; $aExistingData["ingredients"] = $oRecipe->ingredients; $aExistingData["directions"] = $oRecipe->directions; $aExistingData["recipeCategory"] = $oRecipe->recipeTypeID; // edit recipe $oEditForm = new Form(); $oEditForm->data = $aExistingData; if (isset($_POST["update"])) { $oEditForm->data = $_POST; $oEditForm->files = $_FILES; //form validation $oEditForm->checkFilled("recipeTitle"); $oEditForm->checkFilled("authorNotes"); $oEditForm->checkFilled("ingredients"); $oEditForm->checkFilled("directions"); // $oEditForm -> checkFileUpload("imageUpload"); // $oEditForm -> moveFile("imageUpload",$sImageName); if ($oEditForm->valid == true) { //updating details: $oRecipe->title = $_POST["recipeTitle"]; $oRecipe->authorNotes = $_POST["authorNotes"]; $oRecipe->ingredients = $_POST["ingredients"]; $oRecipe->directions = $_POST["directions"]; // $sImageName = "recipeImage".$oRecipe -> title.".jpg"; // $oRecipe -> imagePath = $sImageName; // $oRecipe -> userID = $oCustomer -> userID; // $oRecipe -> recipeTypeID = $_POST["recipeCategory"];
header("Location:index.php"); exit; // terminates request } } } // form markup: $oForm1->makeInput("username", "Username", "clearBoth"); $oForm1->makePassword("password", "Password", "clearBoth"); $oForm1->makeSubmit("signIn", "Sign-In", "blueButton2 bgBlue marginBottom10"); // sign up form $oForm2 = new Form(); if (isset($_POST["create"])) { $oForm2->data = $_POST; // form validation: $oForm2->checkFilled("firstName"); $oForm2->checkFilled("lastName"); $oForm2->checkFilled("username"); $oForm2->checkFilled("email"); $oForm2->checkFilled("address"); $oForm2->checkFilled("telephone"); $oForm2->checkFilled("password"); $oForm2->checkFilled("confirmPassword"); $oForm2->compare("password", "confirmPassword"); $oTestCustomer = new User(); // testing if username exists in database $bLoad = $oTestCustomer->loadByUsername($_POST["username"]); // what username is posted if ($bLoad == true) { $oForm2->raiseCustomError("username", "* this username already exists"); // calls raiseCustomError message
<?php require_once "subscriber.php"; require_once "form.php"; // newsletter sign up $oNewsletterForm = new Form(); if (isset($_POST["subscribe"])) { $oNewsletterForm->data = $_POST; //form validation $oNewsletterForm->checkFilled("email"); $oTestSubscriber = new Subscriber(); $bLoad = $oTestSubscriber->loadByEmail($_POST["email"]); if ($bLoad == true) { $oNewsletterForm->raiseCustomError("email", "* you are already subscribed"); } if ($oNewsletterForm->valid == true) { $oSubscriber = new Subscriber(); $oSubscriber->email = $_POST["email"]; $oSubscriber->save(); // redirect after adding new page successfully to that new location if (isset($_SESSION['url'])) { $url = $_SESSION['&url']; } else { $url = "index.php"; } // default page for header("Location: {$url}?message=subscribed"); // perform correct redirect. exit; // terminates request }
<?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");
} // html markup: $oForm1->makeInput("firstName", "First Name *", "doubleColumn heightApplied floatLeft"); $oForm1->makeInput("lastName", "Last Name *", "doubleColumn heightApplied floatLeft"); $oForm1->makeInput("username", "Username *", "doubleColumn heightApplied floatLeft"); $oForm1->makeInput("email", "Email *", "doubleColumn heightApplied floatLeft"); $oForm1->makeInput("address", "Address *", "doubleColumn heightApplied floatLeft"); $oForm1->makeInput("telephone", "Telephone *", "doubleColumn heightApplied floatLeft"); $oForm1->makeSubmit("updateDetails", "Update Details", "blueButton2 bgBlue marginBottom10"); // change password form $oForm2 = new Form(); $oForm2->data = $aExistingData; if (isset($_POST["changePassword"])) { $oForm2->data = $_POST; // form validation: $oForm2->checkFilled("password"); $oForm2->checkFilled("confirmPassword"); $oForm2->checkFilled("currentPassword"); $oForm2->compare("password", "confirmPassword"); if (password_verify($_POST["currentPassword"], $oCustomer->password) == false) { // incorrect password $oForm2->raiseCustomError("currentPassword", "* incorrect password"); } if ($oForm2->valid == true) { $oCustomer->password = password_hash($_POST["password"], PASSWORD_DEFAULT); $oCustomer->save(); // redirect after adding new page successfully to that new location header("Location:editMyDetails.php?message=passwordChanged"); exit; // terminates request }
require_once "includes/order.php"; $oBasket = $_SESSION["basket"]; $iProductID = 1; if (isset($_GET["ProductID"])) { $iProductID = $_GET["ProductID"]; } $oProduct = new Product(); $oProduct->load($iProductID); $oCustomer = new User(); $oCustomer->load($_SESSION["UserID"]); echo View::renderCheckoutBasket($oBasket); // delivery and billing payment form $oDeliveryPayForm = new Form(); if (isset($_POST["checkout"])) { $oDeliveryPayForm->data = $_POST; $oDeliveryPayForm->checkFilled("name"); if (!isset($_POST["deliveryAdd"])) { $oDeliveryPayForm->checkFilled("delivery"); } if (!isset($_POST["billingAdd"])) { $oDeliveryPayForm->checkFilled("billing"); } $oDeliveryPayForm->checkFilled("paymentType"); $oDeliveryPayForm->checkFilled("accountName"); $oDeliveryPayForm->checkFilled("ccNumber"); $oDeliveryPayForm->checkFilled("expiry"); $oDeliveryPayForm->checkFilled("security"); if ($oDeliveryPayForm->valid == true) { $oOrder = new Order(); $oOrder->orderStatus = "Processing"; $oOrder->recipientName = $_POST["name"];