示例#1
0
require_once '../../php/submit_helper.php';
$json_return['status'] = "NA";
$json_return['message'] = "Could not edit ability.";
try {
    // variables
    $table = 'ability';
    $unique_id = 'name';
    $original_unique_id = 'original_' . $unique_id;
    $exceptions = array($original_unique_id);
    $primary_key = array($unique_id, 'rpg');
    if (inputExists($_POST, $unique_id) && $_POST[$unique_id] !== $_POST[$original_unique_id]) {
        checkDataUnique($database, $_POST, $table, $unique_id, $json_return);
    }
    checkDataValid($database, $_POST, 'abilityType', 'type', $json_return);
    checkDataValid($database, $_POST, 'target', 'target', $json_return);
    if (inputExists($_POST, 'radiusType')) {
        checkDataValid($database, $_POST, 'radiusType', 'radiusType', $json_return);
    }
    checkInputExists($_POST, 'description', $json_return);
    if ($json_return['status'] === "OK") {
        // add rpg
        $_POST['rpg'] = 'dales';
        insertAndDeleteEdit($table, $_POST, $exceptions, $primary_key, $database, $json_return, $unique_id);
    }
} catch (PDOException $e) {
    $json_return['status'] = "FAILED";
    $json_return['message'] = "ERROR: " . $e->getMessage();
}
// send json
header("Content-Type: application/json", true);
echo json_encode($json_return);
示例#2
0
                        } else {
                            if ($_POST['primaryType'] === 'Gear' || $_POST['primaryType'] === 'Miscellaneous' || $_POST['primaryType'] === 'Tool') {
                                // do nothing more
                            } else {
                                $json_return['status'] = "FAILED";
                                $json_return['message'] = 'Not a recognized type.';
                            }
                        }
                    }
                }
            }
        }
    }
    // if everything is still ok after primaryType pass, add to item's table.
    if ($json_return['status'] === "OK") {
        $items_data['rpg'] = $_POST['rpg'];
        $items_data['name'] = $_POST['name'];
        $items_data['weight'] = $_POST['weight'];
        $items_data['value'] = $_POST['value'];
        $items_data['primaryType'] = $_POST['primaryType'];
        $items_data['secondaryType'] = $_POST['secondaryType'];
        $items_data['description'] = $_POST['description'];
        insertAndDeleteEdit($table, $items_data, NULL, $primary_key, $database, $json_return, $unique_id);
    }
} catch (PDOException $e) {
    $json_return['status'] = "FAILED";
    $json_return['message'] = "ERROR: " . $e->getMessage();
}
// send json
header("Content-Type: application/json", true);
echo json_encode($json_return);