Advertisement
Guest User

public_console.php

a guest
Nov 21st, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. session_start();
  5.  
  6.  require 'config.php';
  7.  require 'classes/Page.php';
  8.  require 'classes/consoleyModel.php';
  9.  require 'classes/AbstractView.php';
  10.  require 'classes/Console.php';
  11.  require 'classes/signin_driver.php'; //++++++++++++++++++++++++++++++++++++++++++++++ NEEDS TO CHANGE
  12.  
  13.  // create the Login/Index page object
  14.  $login = new Index;
  15.  // view indicates the HTML file to use and display
  16.  $view = $login->makeView();
  17.  
  18.  // model stores all of our database queries
  19.  $model = $login->makeModel();
  20.  
  21.  // check to see if the user has posted data to the form
  22.  if (empty($_POST)) {
  23.     $findCitizen = $model ->find('citizen',$_SESSION['license']);
  24.    
  25.     if($findCitizen){
  26.         $view->setTemplate('viewpages/public_console.tpl.php');
  27.         $view->display();
  28.     }else{
  29.         header('Location: license_upload.php');
  30.     }
  31.  }
  32.  // data was posted so we must do the following
  33. else {
  34.     // 1. Validate the data if JavaScript didn't do it
  35.     $validator = new Validator($_POST);
  36.     $result = $validator->validate();
  37.     // 2. If the data is invalid, get and display error messages
  38.     if (!$result) { // validation failed, errors were generated
  39.         $errors = $validator->getErrors();  // an array of strings
  40.         $view->setTemplate('viewpages/public_console.tpl.php');
  41.         $view->addVar('errors', $errors);
  42.         $view->addVars($_POST);
  43.         $view->display();
  44.     }
  45. // 3. If the data is valid, update the database and go to next page
  46.     else {
  47.         if ($model->find('citizen', $_POST['natl_id'], $_POST['password']) == true){
  48.             header('Location: public_console.php');
  49.         }
  50.         else {
  51.             $view->setTemplate('viewpages/public_console.tpl.php');
  52.             $view->addVar('errors', 'Invalid national id or password');
  53.             $view->addVars($_POST);
  54.             $view->display();            
  55.         }
  56.        
  57.     }
  58. }
  59.  
  60.  
  61.  
  62.  // set the template file to use
  63.  // $view->setTemplate('registration.html');
  64.  // $view->display();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement