hi there im stuck on a section where there are 2 different users like A and B both have different tables for data the problem is in first user ie “A” the logout login works fine like if he goes back to index page heil his MYPROFILE link where he can visit his profile page but for user B i added the same code but when the user goes to index he can see two profile links one of the user A and his B im using session code in that like this
see the index page has 2 home links the code says if empty show the home line else show the profile page of A or B.if the user B logs in and goes to index page heil see two profile links one of which is his if he clicks on profile ie of A the profile page will open but he wont see cuz its not his session i just want if user A logs in the user B profile shd be hidden vice versa
Surely the easiest way is to have the “profile” code (the code that runs when you click the ‘profile’ link) read the user ID from the session and display the appropriate information? If you think of User A and User B and code for their individual needs, what happens when you have 5000 users?
So, instead of linking to a.php or b.php, you link to profile.php and in the start of that code, read the user ID from the session data.
A and B i typed for easy understanding i hav profile.php n profile2.php i have added a seperate register for USER A and seperate for USER B,and i have a separate data table for user A(PROFILE) and B(profile)so its 10 or 5000 users it will get bifercated according to users registeration see my code
OK, so does that mean A and B are user types, something like admin and non-admin users? Do you have something in the session variables that will tell you which it is? That would seem to be the easiest way, or modify profile.php to contain the code for both user types, and run whichever is appropriate for the user type.
So, all you need to do is have one profile.php page, at the start check in the session variable to see what type of user is logged in and run the appropriate code based on user type. When the user logs in, what do you do? Do you have two login pages depending on what type of user, or do you get their details, look through one table, and if not found look through the other table?
It seems in the above code you get the $_SESSION['login_user'] variable to use in the query, without checking to see if it exists. You check that later, but it would be more benefit to check earlier I think.