I created a custom page. I want to show some information of logged in user. this information only show for that user only. like, My Profile. which code i have to copy/changes? I m new in PhP/Mysql.thats why I asked about the code.
example: if rony is logged in, then if he clicks on custom page then it shows some information from "my profile".
Take a look how this is being accomplished in profile.php. There is not simple, more straightforward answer than that.
Quote from: Joachim Müller on August 09, 2008, 11:09:35 AM
Take a look how this is being accomplished in profile.php. There is not simple, more straightforward answer than that.
I tried to way.
1. declaring a session variable like: $_SESSION['uname']=$_POST['username']; in login.php and print that session from my custom page. but no result was printed.
2. to find out the solution, once i linked my custom page with profile.php and another time, i copied some code in my custom page. but both case i got an error when i clicked on my custom link.
Error
Selected user does not exist !
if i click on my profile. then its work properly. what is the problem i could not find.
thanks Joachim Müller.
I got the solution from another post where u gave this kind of solution.
thank you.
What do you want to display?
If it's all user_data, you can do this:
Create a new .php file in your root directory of the gallery and paste the following:
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader('Your Page Title');
if (USER_ID) { $user_data = $cpg_udb->get_user_infos(USER_ID); }
?>
<!-- Your Content -->
Let's show the user's id: <?php echo $user_data['user_id'] ?>
<br />
Show username: <?php echo $user_data['user_name'] ?>
<!-- Stop Your Content -->
<?php
pagefooter();
?>
That will load the user's data on your custom pages.
Edit: really late. Rony, please post the link to the solution you used, other users may find Joachim Muller's post more helpful