123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
-
- // use x-www-form-urlencoded
- // parameter 'x'
- // value is the actual json
- // extract from $_POST['x']
- // json_decode() it
- // access the obtained object
-
- /*
- {
- "hello" : "world",
- "we" : "are",
- "your" : {
- "first": "val1",
- "second": "val2",
- "third": "val3"
- },
- "mine" : [
- "a",
- "b",
- "c",
- "d"
- ]
- }
- */
-
- // $obj->hello
- // $obj->we
- // $obj->your
-
-
-
- // $obj = json_decode($_POST['x']);
- // print_r($obj);
- // print_r($obj->your);
- // print($obj->your->first);
- // print_r($obj->mine);
-
- // http_response_code(400);
- // echo json_encode($_POST);
- // echo json_encode(array("error" => "No title given."));
-
-
- require_once 'processes/config.php';
- require_once 'processes/dbh.inc.php';
-
- // $result = mysqli_num_rows(mysqli_query($connection, "select * from question where id = 3adsfasdf"));
-
- // var_dump($_POST);
-
- // echo "<br>";
-
- $result = mysqli_real_escape_string($connection, trim($_POST["id"]));
-
- // $_POST["id"] devuelve null si no está definido
- // trim() devuelve "" si el input es null / "" / false
- // mysqli_real_escape_string() devuelve "" si no el input es null / "" / false
-
- // echo "This is result: $result<br>";
-
- if($result === "") {
- // echo "Result is empty string";
- } else {
- // echo "Result isn't empty string";
- }
-
- ?>
|