ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:    
Ambiera Forum > CopperCube > Programming and Scripting
Send value to a database?
Author Text

ddabrahim
Registered User
Quote
2017-12-13 11:08:04

Hi.

I would like to know would it be possible to send a value to a MySQL database somehow?

I know there is a function to send a request to a website and using the GET method receive the value returned from the website.

ccbDoHTTPRequest(url, callback)

On the forum many people asked the same question and all of them getting the same reply, to use this function but I fail to see how it could be done as sending a value would require me to use the POST method but this function using the GET method by default and I can't see a way to change that.

So for example I would POST value 100 to www.xyz.com/process.php
Where the PHP receive the value and process it and write it in to the database. Then to get the value back I can use the above mentioned function to make a request to www.xyz.com/get.php where the PHP going to GET the value form the database and return it that I can use in a callback function.

Is there any built-in solution in CopperCube?
Or how am I supposed to use ccbDoHTTPRequest(url, callback) to POST a value?

If there is no way to do it, probably I can get the values of "CopperCube variables" (?) if I'm correct using Js and then pass the value to PHP using AJAX call or http request but would like to know if there is any easy, built-in solution for this or not?

Anyone could share some thoughts on this?
Thanks.


erik
Registered User
Quote
2017-12-13 17:05:41

there should not be a difference between POST and GET. Unless you try to send very, very large data. I think GET has an upper limit of - I don't know - maybe 1 KB of data? But for games, this should be more than enough.


ddabrahim
Registered User
Quote
2017-12-13 19:43:54

Now that you mention it, the only way to send information using the GET method is putting the query string in to the URL which is not secure as the information you send is visible to anyone in the URL and remain in history of the browser and can be easily exploited.

The POST method is more secure because it is not visible and not stored in the browser.

In general it is always recommended to use POST to send info to a page and use GET to get info from a page.

It is unlikely to be a problem in a Windows game I guess, but in a browser game I would prefer not to go against the recommendations when it comes to security.

It would be nice to have two separated functions in the future to POST and GET just to keep things tidy and simple :)

Thanks for the reply though, I haven't even thought about using the URL to send query strings, that is also a way to do it for sure.


niko
Moderator
Quote
2017-12-15 09:27:52

It's not more secure, not at all. But I see what you mean, I'll probably add this option in an update.


Zoo
Guest
Quote
2017-12-17 01:02:09

Hi guys...

I dont use http anymore ...I write the variable to a text file and I used perl to send the data to and from the server which updates another textfile.

This is how I am building my TCP based multiplayer for Coppercube and it is working wonderfully as TCP is far faster then http..

I have compiled my perl script to exe in order to protect db details.

It is now portable and does not require the environment.

Check out CPAN exe module for perl


ddabrahim
Registered User
Quote
2017-12-17 11:13:58

Thanks.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2018 Nikolaus Gebhardt, Ambiera e.U.