SA-MP Forums Archive
PHP redirect depending on user ID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: PHP redirect depending on user ID (/showthread.php?tid=394091)



PHP redirect depending on user ID - nLs - 21.11.2012

So basically I'm stumped. I'm making a member list for my own website which i already have the usernames and last login displays done. I'm just having troubles with having their username being a redirect to their profile. I can't figure out how to get the page to redirect to their ID.

My Code:

Код:
  <td align="center"><font face="Tahoma" size="2"><?php

include_once "connect_to_mysql.php";

$sql = mysql_query("SELECT * FROM members ORDER BY id asc") or die(mysql_error('No Records Found'));

while($info = mysql_fetch_array( $sql ))
{

print "<a href='member_profile.php?id=$id'>" . $info['username'] . "<br /></a>";
//the $id is what I need help with!

}

?>
</td>



Re: PHP redirect depending on user ID - FarSe. - 21.11.2012

header("Location: /member_profile.php?id=$id");
or
echo "<script>window.location='yoursite.com/member_profile.php?id=%id';</script>";


Re: PHP redirect depending on user ID - nLs - 21.11.2012

Where would that be placed?


Re: PHP redirect depending on user ID - Vince - 21.11.2012

header() statements must be sent before any output is sent to the page. Output also includes echo statement.


Re: PHP redirect depending on user ID - nLs - 21.11.2012

Thank you both! +rep for both.