How do I, use POST method with Ajax and PHP DBOperations?

  • Hey,

    I'm new to the forums, so sorry for not posting screenshots of the problem.

    I have been trying to make a PHP/Mysql, database to create a login.

    I completed like 3 tutorials on the web, and the ones here, like "Simple Login using a MySQL database", and "Creating your own Leaderboard / Highscores easy and free (PHP MySQL)"

    After quite some research and failures, I figured that "Fatal error: Uncaught Error: Call to undefined function mysql_connect()"

    has to do with some deprecated functions of a old PHP, and now people use the DBOperations.

    So, I'm following a Android tutorial on "learn2crack" website, with the name "Android Login Registration System with PHP and MySQL (Updated) – Server #1"...

    I have set up, all the server, database, php files etc. And I'm using Postman, to POST, this request to the server:

    {
       "operation":"register",
       "user":{
            "name":"Raj Amal",
            "email":"raj.amalw@learn2crack.com",
            "password":"rajamalw"
       }
    }[/code:2ilq0ekv]
    
    My question is, the code above, the Register Operation, How I POST that, using Construct 2 events? 
    
    I tried a Event like this:
    Mouse, On left button clicked, on Sprite, AJAX, Send "" to URL "http://127.0.0.1/polar/savescores.php?name=" & txtPlayerName.Text & "&score=" & Score (method "POST", tag "PostScore"). 
    
    But that is not working, anyone has any suggestions?
  • Your elements like

    "score=" & Score[/code:16qnh3sn]
    
    Should be in the "Send" field of the request, not the URL.
    Also never forget AJAX cross-domain request security mentioned in [url=https://www.scirra.com/manual/107/ajax]the manual article[/url].
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey! Thank you for replying! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I did put the "score=" in the Send field, I guess..

    Gonna give one more try today after work <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    (need to assure the "Access-Control-Allow-Origin: *" is ok on the header.. I'm not a programmer so I take sometime to figure out where to put the codes and lines lol)

    I attached CAPX files to google drive here:

    https://drive.google.com/drive/folders/ ... sp=sharing

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