Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // use x-www-form-urlencoded
  3. // parameter 'x'
  4. // value is the actual json
  5. // extract from $_POST['x']
  6. // json_decode() it
  7. // access the obtained object
  8. /*
  9. {
  10. "hello" : "world",
  11. "we" : "are",
  12. "your" : {
  13. "first": "val1",
  14. "second": "val2",
  15. "third": "val3"
  16. },
  17. "mine" : [
  18. "a",
  19. "b",
  20. "c",
  21. "d"
  22. ]
  23. }
  24. */
  25. // $obj->hello
  26. // $obj->we
  27. // $obj->your
  28. // $obj = json_decode($_POST['x']);
  29. // print_r($obj);
  30. // print_r($obj->your);
  31. // print($obj->your->first);
  32. // print_r($obj->mine);
  33. // http_response_code(400);
  34. // echo json_encode($_POST);
  35. // echo json_encode(array("error" => "No title given."));
  36. require_once 'processes/config.php';
  37. require_once 'processes/dbh.inc.php';
  38. // $result = mysqli_num_rows(mysqli_query($connection, "select * from question where id = 3adsfasdf"));
  39. // var_dump($_POST);
  40. // echo "<br>";
  41. $result = mysqli_real_escape_string($connection, trim($_POST["id"]));
  42. // $_POST["id"] devuelve null si no está definido
  43. // trim() devuelve "" si el input es null / "" / false
  44. // mysqli_real_escape_string() devuelve "" si no el input es null / "" / false
  45. // echo "This is result: $result<br>";
  46. if($result === "") {
  47. // echo "Result is empty string";
  48. } else {
  49. // echo "Result isn't empty string";
  50. }
  51. ?>