Datenstand V1.0
This commit is contained in:
68
inhalte/artikel_save.php
Normal file
68
inhalte/artikel_save.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
if ("" != $_SESSION['Firma']['Feld1_Name']) {
|
||||
$Feld1 = "Feld1 = \"".addslashes($_POST['Feld1'])."\",";
|
||||
} else {
|
||||
$Feld1 = "";
|
||||
}
|
||||
if ("" != $_SESSION['Firma']['Feld2_Name']) {
|
||||
$Feld2 = "Feld2 = \"".addslashes($_POST['Feld2'])."\",";
|
||||
} else {
|
||||
$Feld2 = "";
|
||||
}
|
||||
if ("" != $_SESSION['Firma']['Feld3_Name']) {
|
||||
$Feld3 = "Feld3 = \"".addslashes($_POST['Feld3'])."\",";
|
||||
} else {
|
||||
$Feld3 = "";
|
||||
}
|
||||
if ("" != $_SESSION['Firma']['Feld4_Name']) {
|
||||
$Feld4 = "Feld4 = \"".addslashes($_POST['Feld4'])."\",";
|
||||
} else {
|
||||
$Feld4 = "";
|
||||
}
|
||||
if ("" != $_SESSION['Firma']['Feld5_Name']) {
|
||||
$Feld5 = "Feld5 = \"".addslashes($_POST['Feld5'])."\",";
|
||||
} else {
|
||||
$Feld5 = "";
|
||||
}
|
||||
|
||||
if (isset($_POST['new'])) {
|
||||
$sql = "INSERT INTO ".PREFIX."_Artikel (ID) VALUES (NULL);";
|
||||
$stmt = $db->prepare($sql);
|
||||
if (!$stmt) {
|
||||
die ('Datensatz konnte nicht angelegt werden: '.$db->error);
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
die ('Datensatz konnte nicht angelegt werden: '.$stmt->error);
|
||||
}
|
||||
$sql = 'SELECT last_insert_id() AS last';
|
||||
$result = $db->query($sql);
|
||||
$nt = $result->fetch_assoc();
|
||||
$ID = $nt['last'];
|
||||
} else {
|
||||
$ID = $_POST['ID'];
|
||||
}
|
||||
$sql = "UPDATE ".PREFIX."_Artikel SET
|
||||
Bezeichnung = \"".$_POST['Bezeichnung']."\",
|
||||
Datum = CURDATE(),
|
||||
".$Feld1."
|
||||
".$Feld2."
|
||||
".$Feld3."
|
||||
".$Feld4."
|
||||
".$Feld5."
|
||||
Preis = \"".$_POST['Preis']."\"
|
||||
WHERE
|
||||
ID = \"".$ID."\";";
|
||||
$stmt = $db->prepare($sql);
|
||||
if (!$stmt) {
|
||||
die ('Datensatz konnte nicht gespeichert werden: '.$db->error);
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
die ('Datensatz konnte nicht gespeichert werden: '.$stmt->error);
|
||||
}
|
||||
$_POST['ID'] = $ID;
|
||||
echo "<h2>Artikel wurde gespeichert</h2>\n";
|
||||
|
||||
if ("artikel" == $_GET['section']) {
|
||||
include "inhalte/artikel_edit.php";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user