0

Trying to $_GET two variable from a URL generated by a HTML5 Construct 2 embedded game.

http://wordpressexample.com/savescores.php?name=NAME_HERE&score=1337

Using

<?php

/** Sets up the WordPress Environment. */
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');

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

//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$name = strip_tags(mysql_real_escape_string($_GET['name']));
$score = strip_tags(mysql_real_escape_string($_GET['score']));

I have also added the following to the Game index page, which allows me to display WP user ID and so on

/** Sets up the WordPress Environment. */
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');

global $wpdb;

However, I don't seem to be getting anything from the URL regarding the Scores and Name variables

  • 1
    You shouldn't use a standalone file for your AJAX queries, bootstrapping WP like that has a lot of downsides and security risks. Save yourself the hassle and register a REST API endpoint instead – Tom J Nowell Apr 25 at 12:38
  • Thank you for the reply. I'll look into that! – user1903887 Apr 25 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.