// 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 } if ($oForm2->valid == true) { //no errors, therefore creates new user in system: $oCustomer = new User(); $oCustomer->firstName = $_POST["firstName"]; $oCustomer->lastName = $_POST["lastName"]; $oCustomer->username = $_POST["username"]; $oCustomer->email = $_POST["email"]; $oCustomer->address = $_POST["address"]; $oCustomer->telephone = $_POST["telephone"]; $oCustomer->password = password_hash($_POST["password"], PASSWORD_DEFAULT); $oCustomer->save(); $oSubscriber = new Subscriber(); if (isset($_POST["newsSignUp"])) {
<?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/form.php'; require_once 'includes/member.php'; $oForm = new Form(); if (isset($_POST["submit"])) { $oForm->data = $_POST; $oForm->checkRequired("MemberEmail"); $oForm->checkRequired("MemberPassword"); if ($oForm->valid == true) { $oTestMember = new Member(); $bLoaded = $oTestMember->loadByEmail($_POST["MemberEmail"]); if ($bLoaded == false) { $oForm->raiseCustomError("MemberEmail", "Please Enter Valid Email"); } else { if (password_verify($_POST["MemberPassword"], $oTestMember->MemberPassword) == false) { $oForm->raiseCustomError("MemberPassword", "Please Enter Valid Password"); } else { //record the CustomerID to session $_SESSION["MemberID"] = $oTestMember->MemberID; header("Location:viewCategories.php?CategoryID=6"); //redirect to exit; } } } } $oForm->makeTextInput("Email", "MemberEmail"); $oForm->makePasswordInput("Password", "MemberPassword"); $oForm->makeSubmit("Login");
$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 } } // html markup: $oForm2->makePasswordBlank("password", "New Password *"); $oForm2->makePasswordBlank("confirmPassword", "Confirm Password *"); $oForm2->makePasswordBlank("currentPassword", "Current Password"); $oForm2->makeSubmit("changePassword", "Change Password", "displayBlock clearBoth blueButton2 bgBlue marginTop10 marginBottom10");
ob_start(); session_start(); require_once "includes/header.php"; require_once "includes/form.php"; require_once "includes/customer.php"; require_once "includes/cart.php"; $oForm = new Form(); if (isset($_POST["submit"]) == true) { $oForm->data = $_POST; $oForm->checkRequired("Email"); $oForm->checkRequired("Password"); $oCheckCustomer = new Customer(); $bLoaded = $oCheckCustomer->loadByEmail($_POST["Email"]); if ($bLoaded == false) { $oForm->raiseCustomError("Email", '<p class="validate">Bad Email!</p>'); } else { if ($oCheckCustomer->Password != $_POST["Password"]) { $oForm->raiseCustomError("Password", '<p class="validate">Bad Password!</p>'); } } if ($oForm->valid == true) { $_SESSION['CustomerID'] = $oCheckCustomer->CustomerID; $oCart = new Cart(); // // $oCart->add(1); // // $oCart->add(5); // // $oCart->add(5); // // $oCart->add(4); $_SESSION["cart"] = $oCart; //redirect header("Location:my_account.php");
require_once "includes/header.php"; require_once "includes/form.php"; require_once "includes/customer.php"; $oForm = new Form(); if (isset($_POST["submit"]) == true) { $oForm->data = $_POST; $oForm->checkRequired("Name"); $oForm->checkRequired("Address"); $oForm->checkRequired("Phone"); $oForm->checkRequired("Email"); $oForm->checkRequired("Password"); $oForm->checkEqual("Password", "Confirm_Password"); $oTestCustomer = new Customer(); $bLoaded = $oTestCustomer->loadByEmail($_POST["Email"]); if ($bLoaded == true) { $oForm->raiseCustomError("Email", '<p class="validate">Taken!</p>'); } // echo "<pre>"; // print_r($_POST); // echo "</pre>"; if ($oForm->valid == true) { $oCustomer = new Customer(); $oCustomer->Name = $_POST["Name"]; $oCustomer->Address = $_POST["Address"]; $oCustomer->Phone = $_POST["Phone"]; $oCustomer->Email = $_POST["Email"]; $oCustomer->Password = $_POST["Password"]; $oCustomer->save(); header("Location:congrats.php"); exit; }