function makeVillain() { createVillain(); $c_table = 'npc'; if (!empty($_GET['id'])) { $c_data = createDataFromPost($c_table); $constraints = ['id' => $_POST['npc_id']]; updateWithConstratints($c_table, $c_data, $constraints); } }
function addOrUpdate() { $table = "events"; $data = createDataFromPost($table); if (empty($_GET['id'])) { insert($table, $data); } else { update($table, $data); } header("Location: index.php"); die("Redirecting to index.php"); }
<?php include_once '../../config/config.php'; include_once $serverPath . 'utils/db_post.php'; $table = "drinks"; if (!empty($_POST)) { $data = createDataFromPost($table); if (empty($_GET['id'])) { $id = insertAndReturnId($table, $data); } else { update($table, $data); $id = $_GET['id']; } header("Location: index.php"); die("Redirecting to index.php"); } include_once $serverPath . 'resources/templates/adminHead.php'; ?> <div ng-controller="AddEditDrink"> <div class="container-fluid"> <form action="edit.php<?php if (!empty($_GET['id'])) { echo "?id=" . $_GET['id']; } ?> " enctype="multipart/form-data" method="post"> <div class="row"> <div class="col-md-6"> <!-- panel --> <div class="panel panel-default">
function createInsertFromPost($table) { return getInsertStatement($table, createDataFromPost($table)); }