add new matching page
This commit is contained in:
parent
e5e47d5741
commit
6dd8041fe4
3 changed files with 120 additions and 1 deletions
38
ajax.php
38
ajax.php
|
@ -85,6 +85,44 @@ switch($_GET["action"]) {
|
|||
$errormsg = "all values have to be set";
|
||||
}
|
||||
break;
|
||||
case "add_match":
|
||||
$successmsg = "one match added";
|
||||
if (hasval($_POST["found_id"]) && hasval($_POST["lost_id"])) {
|
||||
/* Prepared statement, stage 1: prepare */
|
||||
if (!($stmt = $mysqli->prepare("INSERT INTO matches(f_id, l_id) VALUES (?, ?)"))) {
|
||||
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
}
|
||||
if (!$stmt->bind_param("ii", $_POST["found_id"], $_POST["lost_id"])) {
|
||||
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
}else if (hasval($_POST["found_id"]) && hasval($_POST["ticket_id"])) {
|
||||
if (!($stmt = $mysqli->prepare("INSERT INTO lost_items(was) VALUES (?)"))) {
|
||||
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
}
|
||||
if (!$stmt->bind_param("s", $_POST["ticket_id"])) {
|
||||
$errormsg = "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$lost_id = $mysqli->insert_id;
|
||||
/* Prepared statement, stage 1: prepare */
|
||||
if (!($stmt = $mysqli->prepare("INSERT INTO matches(f_id, l_id) VALUES (?, ?)"))) {
|
||||
$errormsg = "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
|
||||
}
|
||||
if (!$stmt->bind_param("ii", $_POST["found_id"], $lost_id)) {
|
||||
$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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue