megapowerskills's Forum Posts

  • Hello folks. I'm working on a little promotional game for a client. the game is working and I just need to add a feature that takes an input from the player and adds it to a database. I've followed the arcade ed tutorial on high score tables and that is working, now I'm trying to modify the PHP to accept some more variables. They are: Name, email, phone number and 2 booleans, one called 'car' and one called 'insurance'.

    I know nothing about php so it's just trial and error and I thought I'd reach out to try and see if someone could help me on this. Here's my PHP file for saving the data so far (I've edited out my login details):

    <?php

    $db = "database";//Your database name

    $dbu = "user";//Your database username

    $dbp = "pass";//Your database users' password

    $host = "localhost";//MySQL server - usually localhost

    $dblink = mysql_connect($host,$dbu,$dbp);

    $seldb = mysql_select_db($db);

    if(isset($_GET['name']) && isset($_GET['email'])){

         //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks

         $name = strip_tags(mysql_real_escape_string($_GET['name']));

         $email = strip_tags(mysql_real_escape_string($_GET['email']));

          $phone = strip_tags(mysql_real_escape_string($_GET['phone']));

          $car = strip_tags(mysql_real_escape_string($_GET['car']));

          $insurance = strip_tags(mysql_real_escape_string($_GET['insurance']));

         

         $sql = mysql_query("INSERT INTO `$db`.`scores` (`id`,`name`,`email`,`phone`,`car`,`insurance`) VALUES ('','$name','$email','phone','car'','insurance');");

         

         if($sql){

         

              //The query returned true - now do whatever you like here.

              echo 'Your information was saved. Congrats!';

              

         }else{

         

              //The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.

              echo 'There was a problem saving your information. Please try again later.';

              

         }

         

    }else{

         echo 'Your name or score wasnt passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the tags.';

    }

    mysql_close($dblink);//Close off the MySQL connection to save resources.

    ?>

    Thanks in advance to anyone who can assist.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Like it. Definitely got potential

  • Looks really nice. As mentioned above though, the gameplay could use some polish. The attack isn't satisfying enough and it doesn't feel very responsive. I definitely think it's worth making the improvements as it looks so nice.

  • Hi. My name's Phil Atherton. I'm a game artist from the south west of the UK.

    I'm currently doing a lot of work in the iOS game market. I've been using gamesalad up until now but I've noticed that construct 2 seems to have a lot more features and the plugins are a very attractive prospect.

    I manly work on other people's projects but I am also developing my own titles. I'm a child of the 80s so I'm really into retro pixel styles and solid, traditional gameplay.

    I'll see you all around the forums and I'll be posting my creations for all to see.

    Phil