Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php # - edit_news.php
- if (!defined('BASE_URL')) {
- // Need the BASE_URL, defined in the config file:
- require_once('../includes/config.php');
- // Redirect to index page:
- $url = BASE_URL . 'index.php';
- header ("Location: $url");
- exit;
- } // IF (!defined('BASE_URL'))
- if (isset($_POST['edit_team_submit'])) {
- echo "<pre>", print_r($_POST), "</pre>";
- $errors = [];
- $team_id = $_POST['team_id'];
- $team_name = $_POST['team_name'];
- $fk_game_id = $_POST['fk_game_id'];
- $fk_country_id = $_POST['fk_country_id'];
- if ($team_name == "") {
- $errors['team_name'] = "Team skal udfyldes";
- }
- $query = "UPDATE teams
- SET team_name = '$team_name', fk_game_id = '$fk_game_id', fk_country_id = '$fk_country_id'
- WHERE team_id = $team_id";
- $db->query($query);
- // header("Location: index.php?p=teams");
- }
- if (isset($_GET['team-id']) AND $_GET['team-id'] != "") {
- $team_id = $_GET['team-id'];
- $edit_post = get_team($team_id);
- if ($edit_post) {
- // echo "<pre>", print_r($edit_post), "</pre>";
- $team_name = $edit_post-> team_name;
- $fk_country_id = $edit_post-> fk_country_id;
- $fk_game_id = $edit_post-> fk_game_id;
- $country_title = $edit_post-> title;
- $game_title = $edit_post-> game_title;
- ?>
- <section class="clearfix" id="content">
- <!-- Render JavaScript alerts here -->
- <div class="alert-area"></div><a class="page-head" href="?p=teams"><i class="fa fa-newspaper-o"></i> News</a>
- <div class="page page-news page-news-admin-form">
- <form role="form" class="form-horizontal" method="post">
- <input type="hidden" name="team_id" value="<?php echo $team_id; ?>">
- <?php
- if (isset($errors['team_name'])) {
- echo $errors['team_name'];
- }
- ?>
- <div class="form-group">
- <label class="col-sm-3 control-label" for="team_name">Team</label>
- <div class="col-sm-9">
- <input id="team_name" name="team_name" type="text" value="<?php echo $team_name; ?>">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label" for="Country">Country</label>
- <div class="col-sm-9">
- <select id="Country" name="Country" class="form-control">
- <option value="na" selected="">Choose:</option>
- <?php
- $sql1 = "SELECT * FROM countries";
- $result1 = mysqli_query($db, $sql1);
- while ($row1 = mysqli_fetch_assoc($result1)) {
- // echo "<pre>", print_r($row1), "</pre>";
- $fk_country_id = $row1['id'];
- $country_title = $row1['title'];
- echo '<option value="'. $fk_country_id .'">'. $country_title .'</option>';
- }
- ?>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3 control-label" for="Game">Game</label>
- <div class="col-sm-9">
- <select id="game" name="game" class="form-control">
- <option value="na" selected="">Choose:</option>
- <?php
- $sql = "SELECT * FROM games ORDER BY game_id ASC";
- $result = mysqli_query($db, $sql);
- while ($row = mysqli_fetch_assoc($result)){
- $fk_game_id = $row['game_id'];
- $game_title = $row['game_title'];
- echo '<option value="'. $fk_game_id .'">'. $game_title .'</option>';
- }
- ?>
- </select>
- </div>
- </div>
- <div class="form-actions">
- <button type="submit" name="edit_team_submit" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
- <button class="btn btn-default" type="reset"><i class="fa fa-undo"></i> Reset</button>
- </div>
- </form>
- </div>
- </section>
- <?php
- } else {
- header("Location: index.php");
- } // END IF ELSE ($edit_post)
- } else {
- header("Location: index.php");
- } // END IF ELSE (isset($_GET['post-id']) AND $_GET['post-id'] != "")
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement