diff options
author | Mateja <mail@matejamaric.com> | 2020-10-04 17:40:30 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-10-04 17:40:30 +0200 |
commit | e853c2949930fdbf64639893a30565531bf5be9d (patch) | |
tree | 6e69ed60e886aa73733c3f955ee3decc3c43d601 | |
parent | fccd2808992596aed2f5252ba033b958c8e096fc (diff) | |
download | old-php-yota-e853c2949930fdbf64639893a30565531bf5be9d.tar.gz old-php-yota-e853c2949930fdbf64639893a30565531bf5be9d.zip |
found a bug when sending td content
-rw-r--r-- | edit.php | 23 | ||||
-rw-r--r-- | request-edit.js | 2 |
2 files changed, 22 insertions, 3 deletions
@@ -21,6 +21,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI try { $recvData = json_decode(file_get_contents("php://input")); + $recvData->id = clear_input($recvData->id); $recvData->approved = filter_var($recvData->approved, FILTER_VALIDATE_BOOLEAN); $recvData->specialCall = clear_input($recvData->specialCall); @@ -34,10 +35,19 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI $recvData->operatorPhone = clear_input($recvData->operatorPhone); $recvData->qso = clear_input($recvData->qso); + //foreach ($recvData as $key => $value) { + //if ($key == "approved") + //$recvData->approved = filter_var($recvData->approved, FILTER_VALIDATE_BOOLEAN); + //else + //$recvData->$key = clear_input($recvData->$key); + //} + $recvData->$specialCall = strtoupper($recvData->$specialCall); $recvData->$modes = strtoupper($recvData->$modes); $recvData->$operatorCall = strtoupper($recvData->$operatorCall); + //print_r($recvData); + } catch (Exception $e) { die("Can't decode JSON!"); } @@ -61,6 +71,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI $recvData->approved = $recvData->approved === true ? "1" : "0"; $stmt = $conn->prepare($sql); + + //foreach ($recvData as $key => $value) { + //$stmt->bindParam(':'.$key, $recvData->$key); + //} + $stmt->bindParam(':id', $recvData->id); $stmt->bindParam(':approved', $recvData->approved); $stmt->bindParam(':specialCall', $recvData->specialCall); @@ -73,6 +88,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI $stmt->bindParam(':operatorEmail', $recvData->operatorEmail); $stmt->bindParam(':operatorPhone', $recvData->operatorPhone); $stmt->bindParam(':qso', $recvData->qso); + $stmt->execute(); $sendData->action=$recvData->action; @@ -88,10 +104,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI $sendData = null; $sendData->action=$recvData->action; - $sendData->id=$row["id"]; - $sendData->approved=$row["approved"]; + //foreach ($row as $key => $value) { + //$sendData->$key = $value; + //} + $sendData->id=$row["id"]; + $sendData->approved=$row["approved"]; $sendData->specialCall=$row["specialCall"]; $sendData->fromTime=$row["fromTime"]; $sendData->toTime=$row["toTime"]; diff --git a/request-edit.js b/request-edit.js index f6d2c05..3a9e7ba 100644 --- a/request-edit.js +++ b/request-edit.js @@ -13,7 +13,7 @@ function btnAction(action, btn) { frequencies: trData[6].firstElementChild.innerHTML, modes: trData[7].firstElementChild.innerHTML, specialCall: trData[8].firstElementChild.innerHTML, - operatorName: trData[9].firstElementChild.innerHTML, + operatorName: trData[9].firstElementChild.innerText, operatorEmail: trData[10].firstElementChild.innerHTML, operatorPhone: trData[11].firstElementChild.innerHTML } |