PHP redirect depending on user ID
#1

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>
Reply
#2

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

Where would that be placed?
Reply
#4

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

Thank you both! +rep for both.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)