Пример #1
0
</head>

	<?php 
//load nav
require "nav.php";
?>

	<?php 
//connect to database
require 'connection.php';
?>

	<?php 
//insert item into database
if (!empty($_POST)) {
    if (validateUpdate($conn)) {
        $type = $_POST["type"];
        $subtype = split("\\|", $_POST["subtype"])[1];
        $year = isset($_POST["year"]) ? $_POST["year"] : "0";
        $make = $_POST["make"];
        $location = $_POST["location"];
        $quantity = $_POST["quantity"];
        $cost = $_POST["cost"];
        $price = $_POST["price"];
        $seller = $_POST["seller"];
        $description = $_POST["description"];
        $model = isset($_POST["model"]) ? $_POST["model"] : "";
        $s_n = isset($_POST["s_n"]) ? $_POST["s_n"] : "";
        $visible = isset($_POST["visible"]) ? "1" : "0";
        $comment = isset($_POST["comment"]) ? $_POST["comment"] : "";
        $picture_url = "";
</head>

	<?php 
//load nav
require 'nav.php';
?>

	<?php 
//connect to database
require 'connection.php';
?>

	<?php 
//insert location into database
if (!empty($_POST)) {
    if (validateUpdate()) {
        $street = $_POST["street"];
        $city = $_POST["city"];
        $state = $_POST["state"];
        $zip = $_POST["zip"];
        $zip = $zip == null || $zip == '' ? null : $zip;
        $sql = $conn->prepare('INSERT INTO locations(Street, City, State, ZIP)
					VALUES (?, ?, ?, ?)');
        $sql->bind_param('sssi', $street, $city, $state, $zip);
        if (!$sql->execute()) {
            failUpdate();
        }
    } else {
        failUpdate();
    }
}
Пример #3
0
        if (isset($_POST["delete_" . $row["ID"]])) {
            $sql = 'DELETE FROM locations WHERE ID="' . $row["ID"] . '"';
            if (!$conn->query($sql)) {
                failUpdate(1);
            }
        } elseif ($_POST["street_" . $row["ID"]] != $row["Street"]) {
            $check = true;
        } elseif ($_POST["city_" . $row["ID"]] != $row["City"]) {
            $check = true;
        } elseif ($_POST["state_" . $row["ID"]] != $row["State"]) {
            $check = true;
        } elseif ($_POST["zip_" . $row["ID"]] != $row["ZIP"]) {
            $check = true;
        }
        if ($check) {
            if (validateUpdate($row)) {
                $street = $_POST["street_" . $row["ID"]];
                $city = $_POST["city_" . $row["ID"]];
                $state = $_POST["state_" . $row["ID"]];
                $zip = $_POST["zip_" . $row["ID"]];
                $zip = $zip == null || $zip == '' ? null : $zip;
                $sql = $conn->prepare('UPDATE locations SET Street=?, City=?, State=?,
							ZIP=? WHERE ID=?');
                $sql->bind_param('sssii', $street, $city, $state, $zip, $row["ID"]);
                if (!$sql->execute()) {
                    failUpdate(2);
                }
            } else {
                failUpdate(3);
            }
        }