ecb247247's Forum Posts

  • Hi.

    Can anyone recommend a good tutorial for using custom colored fonts (not black & white) and where one could get one, free or paid.

    Here is an example of what i'm thinking about.

    Regards

    Edgar

  • OK..

    Got it working now..

    Thank you, me too. I missed one of the '&' in the second variable.

    Thank you to everyone who helped.

    Regards

    Edgar

  • Its not working.. haha

    I will try again later.. gotta go, lunch time.

    Ok, thanks for trying.

    So then it might be an issue with ajax passing two variables together.

    Anyone else able to replicate this or know if it's actually possible to do this?

    Regards

    Edgar

  • Great, thank you.

    Regards

    Edgar

  • How would i go about doing this? Do i need to open a web browser for each time i update the balance? My intention was to do it from ajax.

    I was thinking to send 2 calls after each other to the server but then it can't really check if the email from the game matches the matches the email in the databse and then update the balance accordingly.

    Can i ask if anyone here can replicate what i'm doing by sending 2 variables from ajax and try to update the user and see if you manage?

    Regards

    Edgar

  • "balance="&balance&"email="&email

    This is incorrect.

    "balance=" & balance & "&email=" & email

    This should work. The space characters are superfluous but help a ton with readability. As Ashley said, preview your data string in the debugger or console and you'll see if it is valid or not.

    I tried to separate it but it still doesn't work, i also tried the trigger once event but to no avail. In the debugger it displays the variable email as the correct email.

    Is it because i'm using the free version and it only allows for 1 variable to be sent?

    Any other suggestions?

    Regards

    Edgar

  • Another update: It seems like when sending both variables together either the database gets populated with an empty email or the email and balance together in the email field. So it seems it doesn't separate the two variables when posting to a php script.

    Is there a way to separate them, because this code should be correct: "balance="&balance&"email="&email

    Regards

    Edgar

  • I'm confused: in your first post you said it's not working, and in the second post you appear to say it is working. I don't know what to say now.

    It's displaying the email from the variable in a text object as you told me to try, so it means that the variable sent in ajax should be correct. Al-tough it's still not updating the data in mysql.

    I posted an update if you saw it that it seems something is wrong with the variable as on random occasions when i start the game it's displaying duplicate emails after each other.

    Would you know why this is happening?

    Regards

    Edgar

  • Update: It seems like on random occasions the text from the email variable displays duplicate emails after each other.

    Regards

    Edgar

  • Thanks for your reply.

    It seems to be displaying the data correctly as seen below. So maybe i should use something instead of the "&" operator or format it differently? As i said using the php script below works when sending from a form.

    Regards

    Edgar

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    i'm trying to send 2 variables together in ajax to a php script to update the user with the balance/score as seen in the photo attached and i'm wondering if i'm doing something wrong? The email and balance are both stored in a global variable so i have added the variable here.

    When i'm sending 1 variable it works and the info gets updated in mysql, but not when sending 2 together.

    I have tested the php script and it works and data gets updated in mysql when sending both variables from a form on my website using an HTML Form with a 'name' & 'balance' input field.

    But it feels like i'm putting the data incorrectly in ajax or the email variable doesn't get sent to the php script.

    Maybe someone here knows what i'm doing wrong?

    Regards

    Edgar

  • Thanks, it works now.

  • Thanks again, appropriate it!

    Although i must be doing something wrong, this is what i have now?

    Maybe i have to do an event to compare the text from the php script and if it matches with 'success' i log in? Or maybe i can't put AJAX.LastData directly into a text field, maybe i have to encode it to a string first?

  • Thanks for the response, i tried that but it didn't work. I am using Wampserver and managed to get it to work by enabling headers_module and by adding this code into httpd.conf:

    <IfModule mod_headers.c>

    Header set Access-Control-Allow-Origin: *

    </IfModule>

    But now i'm facing another problem, do you know how to get a respond from php script/website. I am able to successfully post data from Construct 3 to my php script and data gets stored into mysql database, this will be for registration, but i'm stuck on trying to do a login form.

    So i just have a text input field and a submit button, if the email exists in the php script you get logged in, but how can i get this response back to Construct 3 to tell it the email is valid. is it possible to us a echo command which says successfully registered and then that text gets sent back to Construct 3 and if it does the game can start.

    Hope you have some ideas?

    Thanks.

  • Hi,

    I'm struggling to get AJAX to work.

    I'm using the post command to send data to a PHP script I have on my localhost server, but no data gets sent.

    I read that I have to put this code somewhere for AJAX to be able to communicate with any domain, but I still don't know where to put this code: Access-Control-Allow-Origin: *.

    Can anyone please tell me, and preferably show me an example?

    Thanks!