Improved cable functions

This commit is contained in:
2023-03-02 13:56:07 +01:00
parent 6e4c4236aa
commit 6a5c483c42
6 changed files with 38 additions and 11 deletions

View File

@@ -34,14 +34,16 @@ switch ($submit = form_get_action()) {
case 'insert':
$description = sanitize($_POST['description']);
$color = sanitize($_POST['color']);
$type = sanitize($_POST['cable_type']);
$info = sanitize($_POST['info']);
$sql = "INSERT INTO cable
(cable_description, cable_color, cable_info)
(cable_description, cable_color, cable_type, cable_info)
VALUES
(:description, :color, :info)";
(:description, :color, :type, :info)";
$sth = $dbh->prepare($sql);
$sth->bindValue(':description', $description, PDO::PARAM_STR);
$sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':info', $info, PDO::PARAM_STR);
$sth->execute();
$id = $dbh->lastInsertId();
@@ -53,12 +55,14 @@ switch ($submit = form_get_action()) {
$color = sanitize($_POST['color']);
$length = sanitize($_POST['length']);
$type = sanitize($_POST['cable_type']);
$links = sanitize($_POST['links']);
$info = sanitize($_POST['info']);
$sql = "UPDATE cable
SET cable_description=:desc,
cable_color=:color,
cable_length=:length,
cable_type=:type,
cable_links=:links,
cable_info=:info
WHERE cable_id=:id";
$sth = $dbh->prepare($sql);
@@ -67,6 +71,7 @@ switch ($submit = form_get_action()) {
$sth->bindValue(':length', $length, PDO::PARAM_INT);
$sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':links', $links, PDO::PARAM_INT);
$sth->bindValue(':info', $info, PDO::PARAM_STR);
$sth->execute();
$action = ACT_VIEW;