We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Send Data PHP

Home Forums Puzzles Send Data PHP

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #21492
    chaac
    Participant

    I have a question..
    i want send data with “Send Data” Puzzle to PHP File. But they dont have any request.. no Data sent? The $_POST array was empty..
    Where is the mistake.. i don’t know :scratch:

    But here my simple Test (Result -> int(0)):

    #21495

    Hi,

    if you try to send something really simple such as a piece of text, will the server receive it?

    Chief 3D Verger | LinkedIn | Twitter

    #21496
    chaac
    Participant

    like this .. no :-(

    #21498

    is the Verge3D app launched from the same domain/port as the PHP server?

    Chief 3D Verger | LinkedIn | Twitter

    #21499
    chaac
    Participant

    yes, localhost:80 (xampp-server)

    #21503

    where is your php script located? can you launch it via browser address bar?

    Chief 3D Verger | LinkedIn | Twitter

    #21577
    chaac
    Participant

    yes, all in the same folder on Webserver “http://localhost/verge3d/test.php”.
    I make a Test .. switch POST to GET:
    <?php var_dump(count($_GET)); ?>
    Call WB: http://localhost/verge3d/test.php?test=true
    Resuld: int(1) It’s running :yes:
    I also get a feedback about the 3d scene.. only no POST is transmitted. :unsure:

    #21589

    I’m no PHP expert, but there might be situations when you cannot read POST contents.
    BTW, can you also check if the piece of the JavaScript code behind the send data puzzle (can be seen in the visual_logic.js) works in your setup?

    Chief 3D Verger | LinkedIn | Twitter

    #21602
    chaac
    Participant

    It’s all visible:

    this.procedures[“dophp”] = dophp;
    ..
    function dophp(VAR) {
    console.log(VAR);
    }
    ..
    oActivObj = null;
    registerOnClick(aAllEditableObj, function() {
    objDict = getObjCustomProps(_pGlob.pickedObject);
    if (dictGet(objDict, ‘activ’) == false) {
    outline(aAllEditableObj, ‘DISABLE’);
    oActivObj = _pGlob.pickedObject;
    outline(oActivObj, ‘ENABLE’);
    dictSet(objDict, ‘activ’, true);
    } else {
    outline(oActivObj, ‘DISABLE’);
    dictSet(objDict, ‘activ’, false);
    oActivObj = null;
    }
    sendData(objDict, ‘test.php’, function() {
    dophp(_pGlob.loadedFile);
    });
    }, function() {});

    .. it all works HTML-Elements control 3d-Scene and vice versa.
    In the same html run a $.ajax POST (2 Objects to test.php).. it work’s perfectly. Only the “send data” Puzzle .. send NO data.. no String, no Number, no Object .. nothing.

    #21605
    chaac
    Participant

    ok, i have the solution!! :yahoo:
    The function sendData() send the request Header as Content-type ‘application/json’, and strings as ‘text/plain’. Anyway.. the $_POST Array ist always empty!
    On PHP we must decode the file content as json.. that’s all ;-)

    if (empty($_POST)) {
        $_POST = json_decode(file_get_contents("php://input"), true) ? : [];
    }
    print_r($_POST);

    Result are an full Array!
    Maybe should mention that at “send data” in the help.

    #21614

    glad you worked it out! :good:

    Chief 3D Verger | LinkedIn | Twitter

    #33584
    cukas
    Participant

    I’m trying to send a variable from verge to a php file so then I could make an insert to a data base, but i can’t get any value … I tried to use your last code to decode but no results…

    Attachments:
    You must be logged in to view attached files.
    #33591

    hi,

    does the browser console print any errors?

    Chief 3D Verger | LinkedIn | Twitter

    #33643
    cukas
    Participant

    Hi Yuri, there is no errors… the problem is getting the value, because every time I try to access to that data for example using var_dump returns a null space.
    …do you have any example to simple get variables values from verge to php ?

    #33704
    cukas
    Participant

    Wow I finally did it, as chaac said this need to be on description cause is hard to get data without knowing the decoder
    …also mention that need to echo something and then in the puzzles use loaded data to receive that echo from the php.
    awesome ty all

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.