<?php
include_once("include/db_connection.php");
session_start();
if($_SESSION["adminloggedIn"] == FALSE){
header("Location:admin_login.php");
exit;
}
include('header.php');
include('left1.php');?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Premium Series by Free CSS Templates</title>
<meta name="keywords" content="" />
<meta name="Premium Series" content="" />
<link href="default.css" rel="stylesheet" type="text/css" media="screen" />
<script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>
<title>Untitled Document</title>
</head>
<body>
<div id="wrapper">
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="prtCnt" align="center">
<div id="content" align="center">
<div class="post">
<h2 class="title"> </h2>
<div class="entry">
<?php
$userfinal=$_SESSION['UserName'];
// get the messages from the table.
$get_messages = mysql_query("SELECT message_id FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
echo '<ul>';
for($count = 1; $count <= $num_messages; $count++)
{
$row = mysql_fetch_array($get_messages2);
//if the message is not read, show "(new)" after the title, else, just show the title.
if($row['message_read'] == 0)
{
$msgid=$row['message_id'];
echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a>(New)<br>';
$sql=" UPDATE messages SET message_read='1' WHERE message_id='$msgid'";
mysql_query($sql);
}else{
echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>';
}}
echo '</ul>';
echo '<form name="newmsgfrm" method="post" action="new_message.php">';
echo '<input type="submit" value="Send a New Message">';
echo '</form>';
?>
<?php
echo '<form name="backfrm" method="post" action="index.php">';
echo '<input type="submit" value="Back to Home" action="index.php">';
echo '</form>';
?>
</p>
</div>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebars -->
<!-- end sidebars -->
<div style="clear: both;"> </div>
</div>
<!-- end page -->
</div>
</html>
<?php
include('footer.php');
?>