0

so I am working with Steam API (shouldn't be related to problem).

On my main page I am checking if user has authcode saved in database using this code:

$userAuth = getAuth($steamprofile['steamid']);
if($userAuth == false){
    ?>
    <script>
        promptAuth(<?php echo($steamprofile['steamid']);?>);
    </script>
    <?php
}

$userAuth returns either false or true (depending if database has auth code saved).

If it returns false (not saved/set) it calls a javascript function:

function promptAuth(steam64){   
    bootbox.prompt({
        title: "Enter your Auth Code",
        value: "",
        callback: function(result){
            if(result === null){
                Example.show("Prompt Dismissed");
            }
            else{
                qwest.post('processor.php', {
                    user_steam64: steam64,
                    user_auth: result
                })
                .then(function (xhr, response){
                    console.log(response);
                });
            }
        }
    });
}

steam64 is users ID, I am using bootbox for prompts and dialogs.

I am using qwest for Ajax calls.

So it sends POST request to processor.php file and posts two variables:

user_steam64: which is user's ID.

user_auth: which is users entered input.

This is the process.php:

<?php
if(isset($_POST['user_auth'])){
    require 'steamauth/steamauth.php';
    include ('steamauth/userInfo.php');
    if($_POST['user_steam64'] == $steamprofile['steamid']){
        echo("ok");
    }
    else{
        echo("not ok, received: ".$_POST['user_steam64'].", actual: ".$steamprofile['steamid']);
    }
}
?>

It basically detects POST variable user_auth then verifies sent steam64 with the actual steam64 (to make sure someone didn't modify steam64.

There is a problem however:

Every time I test it I get:

not ok, received: XXXXXXXXXXXXX240, actual: XXXXXXXXXXXXX0233

Replaced my actual steamID with XXX as those parts are always identical, there is always 7 count difference towards ending.

I know this is something simple but I can't figure it out, is there a problem calling JS function from PHP?

AleRemote225
  • 93
  • 1
  • 7
  • As I say in [my answer to that question](http://stackoverflow.com/a/1379973/157247), you'll need to make those strings if you want them to come back identically to what you send, e.g. `` – T.J. Crowder Jun 26 '16 at 13:19
  • 1
    @T.J.Crowder that explains it and the json_encode worked, thanks. – AleRemote225 Jun 26 '16 at 13:21

0 Answers0