cyimking Posted March 20, 2012 Share Posted March 20, 2012 Ok, so im working on a site, and i ran into an error. Its seems to be that when i log in onto a sample account, it goes to the index.php page. Then , in the header, it's a link to go to the user's profile page. The link to their profile page is localhost/mysite/members/profile.php?id='.$id.' And the $id is set to the Session that is currently into play. So if the user id is #1, then in the link will be localhost/mysite/members/profile.php?id=1[/code] BUT if i type in , lets say 2 in the browser, then it should display the second user, but instead it still display the first user. Even if i type in 10000000000000000, it will still go back to the first user. Profile.... <?php include_once "../config.php" ; // MUST include. //Check To make sure a valid session is stored! If not, die message will occur. if (isset($_SESSION['id'])) { // Set up the ID variable. It should be equal to 1. $id = $_SESSION ['id']; //Get variables to make sure the ID exist AND make sure that the user is using the correct ID. $sql = mysql_query("SELECT * FROM members WHERE id = '$id' LIMIT 1"); $check = mysql_num_rows($sql); if ($check > 1) { echo "No one matches that id number!"; exit(); } //Check to make sure that the ID matches another ID in the database if($check == 1) { while($row = mysql_fetch_array($sql)) { //Set up variables from the database $username = $row['username']; $email = $row['email']; $join_date = strftime("%b %d, %Y", strtotime($row['join_date'])); $bio = $row['bio']; $check_pic = "../members/members/$id/pic1.jpg"; $default_pic = "../members/members/0/pic1.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; } else { $user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; } //Check to see what type of member the user is. if ($row['account_type'] == a) { //A users are Admin. $account_type = "Administrator"; } else if ($row['account_type'] == b) { //B users are Moderators $account_type = "Moderator"; } else //Regular Members $account_type = "Regular Member"; } // End while loop! } else die ("Must be logged in to view this page!"); } else die(); ?> Heade include_once"config.php"; //Include the config.php which connects to the server and database $toplinks = ""; if(isset($_SESSION['id'])) { //Setting the local variables based on the login details $id = $_SESSION ['id']; $username = $_SESSION['username']; $toplinks = '<a href ="/empora/members/profile.php?id='.$id.'">'.$username.'</a> <a href="members_account.php"> Account </a> <a href="/empora/logout.php">Log Out</a>'; } else { $toplinks = '<a href="registration.php"> Join Now </a> <a href="login.php">Login Now</a>'; } ?> PS. I am slowly working into making all of this into functions, but this error have to be address first. Quote Link to comment https://forums.phpfreaks.com/topic/259375-id-help/ Share on other sites More sharing options...
max_w1 Posted March 20, 2012 Share Posted March 20, 2012 look at your line which has $id = $_SESSION ['id']; change $_SESSION['id'] to $_GET['id'] tell me if that works Quote Link to comment https://forums.phpfreaks.com/topic/259375-id-help/#findComment-1329658 Share on other sites More sharing options...
cyimking Posted March 20, 2012 Author Share Posted March 20, 2012 Thanks ! It works fine now. Quote Link to comment https://forums.phpfreaks.com/topic/259375-id-help/#findComment-1329662 Share on other sites More sharing options...
max_w1 Posted March 21, 2012 Share Posted March 21, 2012 you are welcome. You may mark this post as solved. Quote Link to comment https://forums.phpfreaks.com/topic/259375-id-help/#findComment-1329670 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.