How to use post method in construct 2

Discussion and feedback on Construct 2

Post » Sat Oct 11, 2014 9:42 am

Hi,

I m new to novice to construct 2, I'm using constuct r178 release.
I have created one capx file for the example .
basically file is used to send textbox value to the php page via POST method and that data is stored into the database.
By doing so I am facing some error because of that I'm not able to retrieve the data in the php file.Please suggest me the solution
Here is the php code for the reference
<?php
/*db connection menthod*/
header("Access-Control-Allow-Origin: *");
$query = mysql_query("insert into score (`score`)values('".$_POST['score']."')");

if($query)
echo "done";
else
echo "notdone";
?>

/*getting error of */

Notice: Undefined index: score in

Please suggest your opinion.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 9
Reputation: 195

Post » Sat Oct 11, 2014 10:41 am

You need to send
Code: Select all
"score=" & val
as the data instead of just val.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sat Oct 11, 2014 10:51 am

Thanks a lot buddy,

is there any way by which we can send multiple data via post method.
also tell me how can I encrypt the data before sending via post method.
and decrypt in php.

Thanks.
B
3
Posts: 9
Reputation: 195

Post » Sat Oct 11, 2014 11:50 am

Hi neocreed,

I use a simple method to encrypt my values. Do some math on the value like ln, log10, etc. plus some multiplication, division. Do that twice using a different approach for the second one, then send both values to the php file, reverse the math and compare the two values, they should be the same.
This is quiet difficult to hack, since you would have to find both math methods and any simple try to fake the values will result in inequality of the two values, so you know they are invalid.

Regards

Frank
B
7
S
1
Posts: 3
Reputation: 331

Post » Sat Oct 11, 2014 6:16 pm

Sending multiple values:
Code: Select all
"score=" & score & "&level=" & level & "&time=" & time
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,670

Post » Sat Oct 11, 2014 6:38 pm

Thanks buddy,

can you also tell me with example.

I'm sending some data from php file like
<?php
echo $data=10;
?>

how can I read the echoed data in construct 2

in the end I wants to read data of php into the construct 2
B
3
Posts: 9
Reputation: 195

Post » Sat Oct 11, 2014 9:25 pm

Make your AJAX call, then in the completed event read the data.
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 3
Reputation: 331

Post » Mon Oct 13, 2014 7:40 am

ramones wrote:Sending multiple values:
Code: Select all
"score=" & score & "&level=" & level & "&time=" & time



It's not working this way,

Can you please send me with example.

Thanks
B
3
Posts: 9
Reputation: 195

Post » Mon Oct 13, 2014 8:16 am

ajax.png
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 3
Reputation: 331


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests