[PHP] Viewing Other Users Profile
Hey Umm on my site when a user clicks another users username its meant to take them the other users profile page. So basically if it was like this:
Medz
So the link there is :
http://www.medz.net78.net/profile.php?user_name=Medz
And basically it dosent come. I dont want to go through the trouble of creating a page for every time a user register and that would be a waste
of time and bandwidth. So basically what I want is when ever someone goes onto someone elses username I want it to show the other users info.
I got a code from the internet but it does not work on my site so does anyone know how I could edit it to work on my site?
PHP Code:
<?
/**
* UserInfo.php
*
* This page is for users to view their account information
* with a link added for them to edit the information.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>
<html>
<title>Medabots Online| View Profile</title>
<body>
<?
/* Requested Username error checking */
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
!eregi("^([0-9a-z])+$", $req_user) ||
!$database->usernameTaken($req_user)){
die("Username not registered");
}
/* Logged in user viewing own account */
if(strcmp($session->username,$req_user) == 0){
echo "<h1>My Account</h1>";
}
/* Visitor not viewing own account */
else{
echo "<h1>User Info</h1>";
}
/* Display requested user information */
$req_user_info = $database->getUserInfo($req_user);
/* Username */
echo "<b>Username: ".$req_user_info['username']."</b><br>";
/* Email */
echo "<b>Email:</b> ".$req_user_info['email']."<br>";
/**
* Note: when you add your own fields to the users table
* to hold more information, like homepage, location, etc.
* they can be easily accessed by the user info array.
*
* $session->user_info['location']; (for logged in users)
*
* ..and for this page,
*
* $req_user_info['location']; (for any user)
*/
/* If logged in user viewing own account, give link to edit */
if(strcmp($session->username,$req_user) == 0){
echo "<br><a href=\"useredit.php\">Edit Account Information</a><br>";
}
/* Link back to main */
echo "<br>Back To [<a href=\"main.php\">Main</a>]<br>";
?>
</body>
</html>
Re: Viewing Other Users Profile
Code:
Error 404 - The Webpage cannot be found
Most likely causes:
* You clicked a link that can be outdated
* You are trying to access file that does not exists on server
* Domain you are trying to access is not configured on this server (website was removed or is not setup or DNS has not propagated yet).
Re: Viewing Other Users Profile
Yeh I know that message comes up but idk what to do to make it work properly.
Re: Viewing Other Users Profile
Change:
Code:
$req_user = trim($_GET['user']);
to:
Code:
$req_user = trim($_GET['user_name']);
Re: Viewing Other Users Profile
Re: Viewing Other Users Profile
Probably not, as that 404 means that profile.php doesn't exist., but if it would exist that would make it work.
Re: Viewing Other Users Profile
Oh wait I got a page for own profile which is status.php so if I change that it would work?
Re: Viewing Other Users Profile
I don't know, why don't you try it?
Re: Viewing Other Users Profile
Uhh it work great now! Thx to passie who did some editing. Anyway now it dosent show the user info. This is the code:
PHP Code:
<?
include("config.php");
?>
<html>
<title>Medabots Online| View Profile</title>
<body>
<?
/* Requested Username error checking */
$req_user = trim($_GET['user_name']);
if(!$req_user || strlen($req_user) == 0 ||
!eregi("^([0-9a-z])+$", $req_user )){
die("Username not registered");
}
/* Logged in user viewing own account */
if(strcmp($session->username,$req_user) == 0){
echo "<h1>My Account</h1>";
}
/* Visitor not viewing own account */
else{
echo "<h1>User Info</h1>";
}
/* Display requested user information */
include("config.php");
$sql2 = "SELECT * FROM `users`";
$query2 = mysql_query($sql2);
while($users = mysql_fetch_array($query2)) {
}
/* Username */
echo "<b>Username: ".$users['username']."</b><br>";
/* Email */
echo "<b>Email:</b> ".$users['email']."<br>";
/**
* Note: when you add your own fields to the users table
* to hold more information, like homepage, location, etc.
* they can be easily accessed by the user info array.
*
* $session->user_info['location']; (for logged in users)
*
* ..and for this page,
*
* $req_user_info['location']; (for any user)
*/
/* If logged in user viewing own account, give link to edit */
if(strcmp($session->username,$req_user) == 0){
echo "<br><a href=\"useredit.php\">Edit Account Information</a><br>";
}
/* Link back to main */
echo "<br>Back To [<a href=\"index.php\">[Back]</a>]<br>";
?>
</body>
</html>
Re: Viewing Other Users Profile
Re: Viewing Other Users Profile
Quote:
Originally Posted by
Pieman
Does config.php exist?
yup it do's don't gonna post because private information
Re: Viewing Other Users Profile
Well this isn't going to get me far now is it? Post some error messages, post the contents of the mysql tables, for god sakes just post more than only the code (which isn't yours in the first place).
Re: Viewing Other Users Profile
Uhh its ok because I got it fixed..........
Edit:
Passie got it fixed XD