Send and save data to php with construct2

716 Views Asked by At

Im trying the past 2 weeks to send and save data to a php but with no luck. So, my goal is , to give the ability to users have download my app from playstore to can vote if they agree or not for something in the app. To do that i put a yes sigh and a no sign , when the user press the yes sign , a vote go to php file and save so all the users can see the results. I make a php

<?php
    $postdata = $_POST['postdata'];
    $getdata = $_GET['getdata'];

    echo("postdata: ");
    if(isset($postdata)) {
        echo ($postdata .", ");
    } else {
        echo ("post data not set, ");
    }

    echo("getdata: ");
    if(isset($getdata)) {
        echo($getdata);
    } else {
        echo("get data not set");
    }
?>

and i send a "POST" whith AJAX on construct2 to URL "https://sirmobilegames.000webhostapp.com/Vote1.php?getdata=gettest"

and the data "postdata=" & URLEncode(ta)

"ta" is a variable in construct with value 1.

and i use METHOD: POST

After i export this to NW.js i run it and when i press the button it says postdata: 1 , getdata: get data not set if i press it once again postdata: 2 , getdata: get data not set so it update the postdata but when i close the app and open it again im trying to read the postdata and i get postdata: post data not set , getdata: get data not set.

Why it cant save the variable i send it.

0

There are 0 best solutions below