Jump to content

PM Notification


Ashoar

Recommended Posts

I have my private message inbox code code here.

At the moment when you recieve a message you dont get a notification, you have to manually go into the inbox and find the new message.

I cant figure it out, could someone help me show unread and read messages and how to add a notification when you recieve a new message so that i can add the new message notification to the members profile page.

 

<?php
session_start();
require_once("header.php");
$user = $_SESSION['username'];

include 'db.php';

if(!$user)
{
echo "<br><p>You arent logged in, Please login or Register</p><br>";
}

else
{
$sql = mysql_query ("SELECT pm_count FROM members WHERE username='$user'");
$row = mysql_fetch_array ($sql);
$pm_count = $row['pm_count'];

$percent = $pm_count/'50';
$percent = $percent * '100';

	?>
<br>
<center>
<b><p><a href="inbox.php">Inbox</a> | <a href="compose.php">Compose</a> | <a href="sent.php">Sentbox</a></b>
<b><p><?php echo "$pm_count"." of 50 Total  |  "."$percent"."% full"; ?></p></b>
</center>
<br>
<?php
	$query = "SELECT id, sender, subject, message FROM messages WHERE reciever='$user'";
$sqlinbox = mysql_query($query);

	if(!$sqlinbox)
	{
	?>
	<p><?php print '$query: '.$query.mysql_error();?></p>
	<?php
	}

elseif (!mysql_num_rows($sqlinbox) )
	{
	?>
	<center><p><b>You have no messages to display</b></p></center>
	<?php
	}

	else
	{
			?>
	<center>
	<form name="send" method="post" action="delete.php">
	<table width="80%">
	<tr>
	  <td width="75%" valign="top"><p><b><u>Subject</u></b></p></td>
	  <td width="120px" valign="top"><p><b><u>Sender</u></b></p></td>  
	  <td width="25px" valign="top"><p><b><u>Select</u></b></p></td>
	</tr>
	<?php

	while($inbox = mysql_fetch_array($sqlinbox))
		{
		$pm_id = $inbox['id'];
		$sender = $inbox['sender'];
		$subject = $inbox['subject'];
					?>
		<tr>
		  <td width="75%" valign="top"><p><a href="viewmsg.php?msg_id=<?php echo $pm_id; ?>"><?php echo $subject; ?></a></p></td>
		  <td width="120px" valign="top"><p><?php echo $sender; ?></p></td>
		  <td width="25px" valign="top"><input name="pms[]" type="checkbox" value="<?php echo $pm_id; ?>"></td>
		</tr>
		<?php
		}
	?>
	<tr>  
	<td colspan="3"><input type="submit" name="Submit" value="Delete Selected"></td>
	<td></td>
	<td></td>
	</tr>
	</table>
	</center>
	<?php
	}

}
require_once("footer.php");
?>

 

 

Thanks

Link to comment
Share on other sites

Yeah sure.

 

CREATE TABLE `messages` (
  `id` int(11) NOT NULL auto_increment,
  `reciever` varchar(25) NOT NULL default '',
  `sender` varchar(25) NOT NULL default '',
  `subject` text NOT NULL,
  `message` longtext NOT NULL,
  `recieved` enum('0','1') NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Link to comment
Share on other sites

Update.

 

Ok i have updated the database with the new field.

Now going back to the php inbox code, what exactly do i need to add to it so that it knows of the new messages and allows me to echo a notification>

The new field name is, newmsg

Link to comment
Share on other sites

Yep that was better.

And under that do i need to put something like:

 

if (newmsg='1')

<p><?php echo "You have new messages" ?></p>

 

so that it says if you have a new message or not, because adding that give another error

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.