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
https://forums.phpfreaks.com/topic/140142-pm-notification/
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
https://forums.phpfreaks.com/topic/140142-pm-notification/#findComment-733260
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.