<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/config/config.php';
/* Making data validation. */
$formValidation = new FormValidator($_REQUEST);
$validationResault = $formValidation->validate();
/* If data are not valid display warnings */
if (isset($validationResault[0][0]) == 'FALSE') {
    $warnings = $validationResault[1];
    /* If AJAX return warnings array. */
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        echo 'window.location = "http://savchenkoportfolio/aprimindtask/view/warnings_form.php"';
        return $warnings;
    }
    include_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/view/warnings_form.php';
    /* If data are valid insert them into DB. */
} else {
    $insertData = new CreateData();
    $insertData->insert($validationResault);
    /* If AJAX return relocation. */
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        echo "window.location = 'http://savchenkoportfolio/aprimindtask/controllers/showController.php'";
        return;
    }
    $showData = new ReadData();
    $data = $showData->read();
    include_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/view/resaults.php';
}
Esempio n. 2
0
    <?php 
session_start();
// Controller "includes" & reads all of your database connections
// & business logic for this app
//
include "models/Views.Class.php";
include "models/CreateData.Class.php";
include "models/ReadData.Class.php";
include "models/UpdateData.Class.php";
include "models/DeleteData.Class.php";
include "models/Login.Class.php";
include "models/DBCredentials.php";
// Instantiate and make new copies of you Classes inside files above
// Store in variables so that we can work with them later
$views = new Views();
$create = new CreateData();
$read = new ReadData();
$update = new UpdateData();
$delete = new DeleteData();
$login = new Login();
// Controller starts routing the user based on the form "action" from Views;
//Process if the action is not empty, if so move to next if statement
//if statements act like switches for when a neccesary model is called upon from user at view
//selected action can be seen in url
// ! its important to have consistent $salt phrase unless database connection won't work for retrival
if (!empty($_GET["action"])) {
    if ($_GET["action"] == "home") {
        //Shows Header & Both Forms; Then, show footer
        $views->getView("views/header.php");
        $views->getView("views/signup_form.php");
        $views->getView("views/login_form.php");