prepare("INSERT INTO feature_request(title, `desc`) VALUES (?, ?)"))) { $errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; }else if (!$stmt->bind_param("ss", $_POST["title"], $_POST["desc"])) { $errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; }else if (!$stmt->execute()) { $errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } }else{ $errormsg = "all values have to be set"; } break; case "add_found": if (hasval($_POST["was"]) && hasval($_POST["wann"]) && hasval($_POST["wo"])) { /* Prepared statement, stage 1: prepare */ if (!($stmt = $mysqli->prepare("INSERT INTO items(was, wann, wo) VALUES (?, ?, ?)"))) { $errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; } if (!$stmt->bind_param("sss", $_POST["was"], $_POST["wann"], $_POST["wo"])) { $errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { $errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } }else{ $errormsg = "all values have to be set"; } break; case "add_lost": if (hasval($_POST["was"]) && hasval($_POST["wann"]) && hasval($_POST["wo"]) && hasval($_POST["contact"])) { /* Prepared statement, stage 1: prepare */ if (!($stmt = $mysqli->prepare("INSERT INTO lost(was, wann, wo, contact) VALUES (?, ?, ?, ?)"))) { $errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; } if (!$stmt->bind_param("ssss", $_POST["was"], $_POST["wann"], $_POST["wo"], $_POST["contact"])) { $errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { $errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } }else{ $errormsg = "all values have to be set"; } break; case "get_stats"; echo json_encode(array("status"=>"ok","stats"=>get_stats())); break; default: $errormsg = "action unknown"; break; } if(empty($errormsg)) echo json_encode(array("get"=>$_GET,"post"=>$_POST,"status"=>"ok","message"=>"added one item")); else echo json_encode(array("get"=>$_GET,"post"=>$_POST,"status"=>"error","message"=>$errormsg)); ?>