I would elaborate further on this if I could, but the main problem I'm having is I can't access a variable outside of a function. I've tried both methods which I have below.
Here is my source:
function register($rand, $code) {
global $rand, $access_token;
if ($code == $access_token)
$rand = rand('100000','1000000');
}
echo $rand;