Hi first off im new to this forum so not sure if i should post this under newbie or here so guess ill try this first 🙂
I'm currently working on a project for a social networking type of website , from reading tutorials i have gotten login/register/private messaging all working through adapting the codes for my own needs but now i hit a stumbling block and cant see why
For my PMS users can click on the subject and be shown a basic page with all the info based of the selected msg_id , i thought i could use this same principle based off the sender/reciever to show a basic user Profile page.
Here is the code for viewmsg.php deleted all the unnecessary stuff to cut it down
<?php
require_once('auth.php');
require_once('config.php');
require_once('opendb.php');
session_start();
$user = $_SESSION['SESS_USERNAME'];
if(!$user)
{
echo "arent logged in </p><br>";
}
else
{
$msg_id = $_REQUEST['msg_id'];
$view_msg = mysql_query("SELECT * FROM messages WHERE id = '$msg_id'");
$msg = mysql_fetch_array($view_msg);
$reciever = $msg['reciever'];
$sender = $msg['sender'];
$subject = $msg['subject'];
$message = $msg['message'];
if($reciever == $user || $sender == $user)
{
mysql_query("UPDATE messages SET recieved='1' WHERE id = '$msg_id'");
$sql = mysql_query ("SELECT pm_count FROM members WHERE login='$user'");
$row = mysql_fetch_array ($sql);
$pm_count = $row['pm_count'];
?>
<br>
<center>
<b><p><a href="inbox.php">Inbox</a> | <a href="compose.php">Compose</a> | <a href="sent.php">Pending Messages</a></b>
</center>
<br>
<table width="80%">
<tr>
<td width="120px"><p>From:</p></td>
<td width=""><p><a href = "user_Profile.php?user_name=<?php echo $sender; ?>"><?php echo $sender; ?></td>
</tr>
<tr>
<td width="120px"><p>Subject:</p></td>
<td width=""><p><?php echo $subject; ?></p></td>
</tr>
<tr>
<td width="120px"><p>Message Body:</p></td>
<td width=""><p><?php echo $message; ?></p></td>
</tr>
</table>
</center>
<?php
}
else
{
?>
<p>view someone else's </p>
<?php
}
}
?>
I thought using them principles i could make a Profile page but even when creating a even more basic than viewmsg.php i am getting errors of kind
<?php
require_once('auth.php');
require_once('config.php');
require_once('opendb.php');
session_start();
$user = $_SESSION['SESS_USERNAME'];
if(!$user)
{
echo "<br><p>Blah blah you arent logged in </p><br>";
}
else
{
//We need to grab the login name variable from the URL.
$user_id = $_REQUEST['user_id'];
$view_profile = mysql_query("SELECT * FROM members WHERE login = '$user_id'");
$user = mysql_fetch_array($view_profile);
$login = $user['login'];
$dob = $user['dob'];
print ("spam !! : $view_profile <BR>");
print ("UserName for login is : $login<BR>");
print ("Date of birth is : $dob");
}
?>
But the output is as follows
spam !! : Resource id #6
UserName for login is :
Date of birth is :
Now i know a few of you have probably banged your head against the screen but if any of you could help it'd be much appreciated.
Thanks
Pages
MOD EDIT: [noparse]
..
tags replaced with
..
bbcode tags - please use these more specific tags when posting PHP code in the future![/noparse]