Example #1
0
<?php

#####################################################################
#
#   File          : EDIT NEWS
#   Project       : Game Magazine Project
#   Author        : Béo Sagittarius
#   Created       : 07/01/2015
#
#####################################################################
include '../includes/backend/mysqli_connect.php';
include '../includes/functions.php';
include '../includes/errors.php';
$title_page = 'Edit News';
if ($nid = validate_id($_GET['nid'])) {
    $result = get_news_item($nid);
    if (mysqli_num_rows($result) == 1) {
        $news = mysqli_fetch_array($result, MYSQLI_ASSOC);
    } else {
        redirect_to('admin/list_news.php');
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $errors = array();
        // validate title
        if (empty($_POST['title'])) {
            $errors[] = "title";
        } else {
            $title = mysqli_real_escape_string($dbc, strip_tags($_POST['title']));
        }
        // validate type
        if (isset($_POST['type_id']) && filter_var($_POST['type_id'], FILTER_VALIDATE_INT, array('min_range' => 1))) {
Example #2
0
<!--#####################################################################
    #
    #   File          : EDIT GAME
    #   Project       : Game Magazine Project
    #   Author        : Béo Sagittarius
    #   Created       : 07/01/2015
    #
    ##################################################################### -->
<?php 
include '../includes/backend/mysqli_connect.php';
include '../includes/functions.php';
$title_page = 'Edit Game';
if ($gid = validate_id($_GET['gid'])) {
    $result = get_news_item($gid);
    if (mysqli_num_rows($result) == 1) {
        $games = mysqli_fetch_array($result, MYSQLI_ASSOC);
    } else {
        redirect_to('admin/list_games.php');
    }
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $errors = array();
        // validate title
        if (empty($_POST['title'])) {
            $errors[] = "title";
        } else {
            $title = mysqli_real_escape_string($dbc, strip_tags($_POST['title']));
        }
        // validate type
        if (isset($_POST['type_id']) && filter_var($_POST['type_id'], FILTER_VALIDATE_INT, array('min_range' => 1))) {
            $type_id = $_POST['type_id'];
        } else {