Implemented Edit Found Items
This commit is contained in:
parent
03655c579b
commit
efe17de00c
3 changed files with 289 additions and 2 deletions
43
ajax.php
43
ajax.php
|
@ -97,6 +97,49 @@ switch($_GET["action"]) {
|
|||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$successmsg = "one item deleted";
|
||||
}else{
|
||||
$errormsg = "id not set";
|
||||
}
|
||||
break;
|
||||
case "edit_found_item":
|
||||
if(hasval($_POST["id"]) && hasval($_POST["was"]) && hasval($_POST["wann"])) {
|
||||
/* Prepared statement, stage 1: prepare */
|
||||
$was=$_POST["was"];
|
||||
if (!($stmt = $mysqli->prepare("UPDATE found_items SET was=?, wo=?, `date`=? WHERE id = ?"))) {
|
||||
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
}
|
||||
if (!$stmt->bind_param("sssi", $_POST["was"] , $_POST["wo"], $_POST["wann"], $_POST["id"])) {
|
||||
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
|
||||
if(isset($_FILES["image"])){
|
||||
if(!file_exists ( "upload/")){
|
||||
mkdir("upload/");
|
||||
}
|
||||
|
||||
$hash = md5($_FILES['image']['name'].time());
|
||||
if(move_uploaded_file($_FILES['image']['tmp_name'], "upload/".$hash)){
|
||||
if (!($stmt = $mysqli->prepare("INSERT INTO files(hash, item_id) VALUES (?, ?)"))) {
|
||||
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
}
|
||||
if (!$stmt->bind_param("si", $hash, $_POST["id"])) {
|
||||
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$successmsg = "one item edited";
|
||||
}else{
|
||||
$errormsg = "upload failed";
|
||||
}
|
||||
}else{
|
||||
$errormsg = "upload failed";
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$errormsg = "id not set";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue