$oForm->data = $_POST;
    $oForm->checkRequired("MemberName");
    $oForm->checkRequired("MemberPassword");
    $oForm->checkRequired("MemberEmail");
    //checkEqual doesn't work.
    $oForm->checkEqual("MemberPassword", "ConfirmPassword");
    if ($oForm->valid == true) {
        $oNewMember = new Member();
        $oNewMember->MemberName = $_POST["MemberName"];
        $oNewMember->MemberPassword = password_hash($_POST["MemberPassword"], PASSWORD_DEFAULT);
        $oNewMember->MemberEmail = $_POST["MemberEmail"];
        $oNewMember->save();
        header("Location:login.php");
        exit;
    }
}
$oForm->makeTextInput("Name", "MemberName");
$oForm->makePasswordInput("Password", "MemberPassword");
$oForm->makePasswordInput("Confirm Password", "ConfirmPassword");
$oForm->makeTextInput("Email", "MemberEmail");
$oForm->makeSubmit("Register!");
?>
<div class="mainBackground">
    <h3>Register</h3>
    <?php 
echo $oForm->html;
?>
</div>    

    <?php 
require_once 'includes/footer.php';
}
$oForm = new Form();
if (isset($_POST["submit"])) {
    $oForm->data = $_POST;
    $oForm->checkRequired("CategoryName");
    $oForm->checkRequired("CategoryDesc");
    if ($oForm->valid == true) {
        $oNewCategory = new Category();
        $oNewCategory->CategoryName = $_POST["CategoryName"];
        $oNewCategory->CategoryDesc = $_POST["CategoryDesc"];
        $oNewCategory->save();
        header("Location:viewCategories.php?CategoryID=6");
        exit;
    }
}
$oForm->makeTextInput("Category Name", "CategoryName");
$oForm->makeTextInput("Category Description", "CategoryDesc");
$oForm->makeSubmit("Post");
?>

<div class="mainBackground">
    <h3>New Category</h3>
    <?php 
echo $oForm->html;
?>
</div>




<?php 
$oForm = new Form();
$oForm->data = $aExistingData;
if (isset($_POST["submit"]) == true) {
    $oForm->data = $_POST;
    $oForm->checkRequired("Name");
    $oForm->checkRequired("Address");
    $oForm->checkRequired("Phone");
    $oForm->checkRequired("Email");
    if ($oForm->valid == true) {
        $oExistingCustomer->Name = $_POST["Name"];
        $oExistingCustomer->Address = $_POST["Address"];
        $oExistingCustomer->Phone = $_POST["Phone"];
        $oExistingCustomer->Email = $_POST["Email"];
        $oExistingCustomer->save();
        header("Location:my_account.php?CustomerID=" . $oExistingCustomer->CustomerID);
        exit;
    }
}
$oForm->makeTextInput("Name", "Name");
$oForm->makeTextInput("Address", "Address");
$oForm->makeTextInput("Phone", "Phone");
$oForm->makeTextInput("Email", "Email");
$oForm->makeSubmit("Update");
?>
	<h3>Edit Details</h3>

	<?php 
echo $oForm->html;
?>

        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");
?>
<div class="mainBackground">
<h3 class="titleHeader">Login</h3>

<?php 
echo $oForm->html;
?>
<h3 class="titleHeader">Dont have an account? <a href="register.php">Register Here</a></h3>
</div>

    

            $oNewTopic->TopicSubject = $_POST["TopicSubject"];
            $oNewTopic->TopicDesc = $_POST["TopicDesc"];
            $oNewTopic->CategoryID = $_GET["CategoryID"];
            $oNewTopic->MemberID = $_SESSION["MemberID"];
            $oNewTopic->save();
            $oNewPost = new Post();
            $oNewPost->PostContent = $_POST["PostContent"];
            $oNewPost->TopicID = $oNewTopic->TopicID;
            $oNewPost->MemberID = $_SESSION["MemberID"];
            $oNewPost->save();
            //make this redirect to viewCategories.php
            header("Location:viewCategories.php?TopicID=" . $oNewTopic->TopicID);
            exit;
        }
    }
    $oForm->makeTextInput("Topic Subject", "TopicSubject");
    $oForm->makeTextInput("Topic Description", "TopicDesc");
    $oForm->makeTextArea("Post Content", "PostContent");
    $oForm->makeSubmit("Post");
}
?>
<div class="mainBackground">
    <h3>Create New Topic</h3>
    <?php 
echo $oForm->html;
?>
</div>



<?php 
Example #6
0
    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");
        exit;
    }
}
$oForm->makeTextInput("Email", "Email");
$oForm->makePasswordInput("Password", "Password");
$oForm->makeSubmit("Log In");
?>

<?php 
echo $oForm->html;
?>

<?php 
require_once "includes/footer.php";
require_once 'includes/member.php';
$iMemberID = $_SESSION["MemberID"];
$oExisitingMember = new Member();
$oExisitingMember->load($iMemberID);
$aExisitingData = [];
$aExisitingData["MemberName"] = $oExisitingMember->MemberName;
//photo should go in here too to edit photo.
$oForm = new Form();
$oForm->data = $aExisitingData;
if (isset($_POST["submit"])) {
    $oForm->data = $_POST;
    $oForm->checkRequired("MemberName");
    //photo should go in here too to edit photo.
    if ($oForm->valid) {
        $oExisitingMember->MemberName = $_POST["MemberName"];
        $oExisitingMember->save();
        header("Location:profile.php");
    }
}
$oForm->makeTextInput("Member Name", "MemberName");
$oForm->makeSubmit("Update Details");
?>
<div class="mainBackground">
	<h3>Edit Details</h3>

	<?php 
echo $oForm->html;
?>
</div>
<?php 
require_once 'includes/footer.php';