2

I have some gameservers and players can use keywords to open websites in the game. Now I want to give them the possibility to see their own profile page usings the keyword "/me" what it does is, it will open a link that looks like this "http://mywebsite.net/me.php?&NEWID=STEAM_0%3a1%3a40577662&SRVIP=145.226.237.229&SRVPORT=27030"

now problem 1 is that the NEWID part needs to be converted into an other format, I use

$split = explode(":", $_GET[ 'NEWID' ]); // STEAM_?:?:??????? format

$x = substr($split[0], 6, 1);
$y = $split[1];
$z = $split[2];

$namesearch = ($z * 2) + 0x0110000100000000 + $y;

It will give me the right format I need a 17 digit number like 45687654326787987 This number I use to do a database lookup to find the userid we use on our website with the following code;

// echo $namesearch. "<br>";

include 'db_login_details.php';

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
  if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
} 
//echo "Connected successfully";
//echo "<br>";

$sql = "SELECT * FROM users WHERE loginname LIKE $namesearch";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
while($row = $result->fetch_assoc()) {
    //echo "Your username: " . $row["username"]. "<br>";
    //echo "Your userID: uid" . $row["uid"]. "<br>";
    $uid = $row["uid"];
    //echo $uid;
}
} else {
//echo "0 results";
}

$conn->close();

Now once I have all the info I needed I want to open the right profile page with

header( 'http://mywebsite.net/member.php?action=profile&uid=' .$uid );

And that last step fails, I know you may not echo anything before redirecting, that's why I commented all the echo lines, they are just there to check my code but it's still not working. Anybody has a solution for me?

Best regards, Jacques

1 Answer 1

2

The problem is because you're not defining the Location so for example it should look like this:

header( "Location: http://mywebsite.php?action=profile&uid=" . $uid );
Sign up to request clarification or add additional context in comments.

2 Comments

Zachary !!!!!!!!!!!! THANKS, I just overlooked it, been pulling my hair for hours because I did not knew what I was doing wrong. Million thanks.
Glad to help! If you feel this is the correct answer please mark the check mark indicating this is your accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.