<?php session_start(); /** * Deletes a DVD from the database. The user has already passed a confirmation page. */ require_once "dvd-db.php"; require_once "dvd-util.php"; ensure_authenticated(); if (array_key_exists('delete_dvd', $_SESSION)) { $dvd = $_SESSION['delete_dvd']; $title = $dvd[0]; delete_dvd($title); add_message("DVD ({$title}) successfully deleted."); } else { add_error("Error - no DVD selected to delete!\n"); } unset($_SESSION['delete_dvd']); header("Location: index.php");
function __construct() { parent::__construct(); // Make sure the user is authorized - all actions ensure_authenticated(); }
public function __construct() { parent::__construct(); // Ensure user is authorized - all actions ensure_authenticated(); }
public function search($name = '') { // Should be moved into another controller // Ensure user is authorized to view the page ensure_authenticated(); $viewdata = array(); if ($_POST) { $this->load->model("user/SearchInput"); // Validate form input if ($this->SearchInput->is_valid()) { // Success // Search the database $this->load->model('user/UserModel'); $result = $this->UserModel->get_all_by_name($this->SearchInput->get_name()); // Pass input model instead and use interface then it could be extended in the future // If any results found add to the viewdata if ($result != null) { $viewdata['result'] = $result; } } } $this->template->load('user/search', $viewdata); }