droptank21's Forum Posts

  • I think I have an idea of the root issue...the AJAX post, when it submits the data to the php page, does not maintain the session.

    Ashley, is that possible?

  • Disregard...that didn't work either. Having a look at your capx now.

  • I think I know what's wrong. On the event sheet I have Button->On Clicked.

    Instead I need to add the mouse plugin and have Mouse->left click on Button.

    I've been clicking on the dang button expecting it to run the AJAX request but never added the mouse control to do so.

    <img src="smileys/smiley18.gif" border="0" align="middle" />

  • Did not work on either hosted site or on localhost server, even after adding: header('Access-Control-Allow-Origin: *');

    I am at a total loss.

  • I have modified the php to the below, however, it only updates the database if I physically plug in the url plus ?&score=1 into the browser bar. Clicking on the button to call up the AJAX doesn't run the function.

    <?php

    include 'connect.php';

    session_start();

    ?>

    <center>

    </center><br><br>

    <?php

    if (isset($_SESSION['player']))

    {

        $player=$_SESSION['player'];

        $userstats="SELECT * from km_users where playername='$player'";

        $userstats2=mysql_query($userstats) or die("Could not get user stats");

        $userstats3=mysql_fetch_array($userstats2);

    if (isset($_REQUEST['score'])){   

        

        $score=$_REQUEST['score'];

        $updatestats="update km_users set skillpts=skillpts+$score where ID='$userstats3[ID]'";

                mysql_query($updatestats) or die("Could not update stats");

                

         

    }else{

         echo 'Score not passed in the request.';

    }

    }

    ?>

    Attached capx: http://dl.dropbox.com/u/44787590/corporal_sanders_1/Corporal_Sanders_1.capx

  • I'm using apache server and xampp on my laptop as host. Comes with everything I need including phpmyadmin.

    As far as securing your php code, you seem to know way more about this stuff than I do. I'm a novice. But...the only thing I've learned of is adding the below to your mysql connect coding:

    if(!get_magic_quotes_gpc())

    {

    $_GET = array_map('mysql_real_escape_string', $_GET);

    $_POST = array_map('mysql_real_escape_string', $_POST);

    $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);

    }

    else

    {

       $_GET = array_map('stripslashes', $_GET);

       $_POST = array_map('stripslashes', $_POST);

       $_COOKIE = array_map('stripslashes', $_COOKIE);

       $_GET = array_map('mysql_real_escape_string', $_GET);

       $_POST = array_map('mysql_real_escape_string', $_POST);

       $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);

    }

  • I'll examine your php. In the mean time, here is my newest attempt for the php code:

    <?php

    include 'connect.php';

    session_start();

    ?>

    <center>

    </center><br><br>

    <?php

    if (isset($_SESSION['player']))

    {

        $player=$_SESSION['player'];

        $userstats="SELECT * from km_users where playername='$player'";

        $userstats2=mysql_query($userstats) or die("Could not get user stats");

        $userstats3=mysql_fetch_array($userstats2);

    if (isset($_POST['score'])){   

        

        $score=$_POST['score'];

        }

        $updatestats="update km_users set skillpts=skillpts+$score where ID='$userstats3[ID]'";

                mysql_query($updatestats) or die("Could not update stats");

                

         

    }else{

         echo 'Your score wasnt passed in the request.';

    }

    ?>

    My attempt is to update existing data in the database by having the POST data from AJAX added to the users skillpts in the database. So far nothing has yet worked and I keep getting a lot of "Undefined varibale" errors when trying to do it the way that makes logical sense.

    I must be missing something.

  • I hope not. It's on localhost, using xampp.

  • I am having an issue figuring out AJAX Post. Basically i want the player to be able to click a button, AJAX sends info to a php page which in turn updates a stat in a mysql database.

    So far it isn't working. Can anyone tell me what I may be doing wrong?

    Files: DropBox Files

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry. Yes, I dropped that url. Will upload to dropbox when I get the opportunity.

  • .csv? or xml?

  • Think King's Quest type games. And, yes, I'm making that style of game...and it is a lot easier than I expected.

  • Goodwill - they will help find employment and train you in new skills to land a job. And focus on employment before you sit down and stress about building a Tycoon game. IMO

  • For the record, I had already voted early yesterday. But I did notice that each time I checked the site I could always vote again. Not change my vote, mind you, but actually vote a second time.

    Since then (yesterday), it appears as if that glitch has been fixed, as I don't have the option of casting a vote anymore.