way to communicate with php pages?

This forum is currently in read-only mode.
From the Asset Store
Template for making an interactive book or a simple story book
  • Will there ever be a way to make a game communicate with a php file.

    For instance i am making a web-rpg and it would be so much more awesome if i could make a desktop game that can communicate with it.

  • You could try using the Download object to download a page such as myfile.php?data=1234...

  • You could try using the Download object to download a page such as myfile.php?data=1234...

    But that wouldn't actually do anything useful, i wouldn't be able to send anything back to the page so the database gets updated with what i do on the desktop version?

  • You can pass information to the server in the query string, and return values from the server in the page that is generated. That's two way communication. What else do you need?

  • So if i tell it on startup to download "text.php?name=test"

    And have my php file add "test" to a database field if it is there, it should work then your saying?

    But there is no way to check if something was right, for example if i wanted the user to login, i can't check if username or password is wrong from the one in the database.

  • Yes you can,

    "SELECT * FROM `login` WHERE user='" urlencode($_GET['user']) . "';'"

    (note this is an example.. there's much better tutorials on this all over the internet)

    then see if the login was successful, and if so

    echo "LOGGEDIN";

    The download object could be modified to download a file into memory, to make this easier, but communication with PHP and ASP is possible.

  • That is fine but how do i let the desktop app now if they have been able to login, echoing "loggedin" is fine on the script, but it doesnt exactly tell the desktop app that they are ok now does it?

  • I think you misunderstand how PHP works. If the download object requests a page then it'll execute the script on it and download the result, in this case LOGGEDIN.

  • Ah i didn't know that, i will give it a go then see what i can come up with.

    What would be a good way to check the login then, do i need to open the downloaded file and check it for a string saying "loggedin" ?

  • I think you are getting confused between server side and client side applications.

    Using an external PHP page to check if someone is logged in to allow access to a desktop application is possible but an awkward way to solve a problem.

    I had a similar problem once, and all you need to do is create a file (or a collection of files) that return results to specific queries and then your desktop application would parse the output.

    As rich and ashley have said, if you download the file the server will be downloading it much in the same way a web user would download it. The server is still executing the script before it uploads it to the client.

    Tom

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • this is all sounds too confusing to me, i cant really be assed with it

  • <img src="http://i112.photobucket.com/albums/n176/lvdonkey/99g9lj.gif">

  • <img src="http://i112.photobucket.com/albums/n176/lvdonkey/99g9lj.gif">

    Exactly my thoughts when trying to make sense of it in this heat

  • lol

  • Well, I learned something from this, at least. I may very well try this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)