dean7 Posted April 25, 2009 Share Posted April 25, 2009 hi, ive coded a inbox and an thing that when someone messages you you get a number/pic saying you have got a message. this is the code ive got so when you get a message it tells you <?php ob_start(); include("config.php"); ?> <?php echo ("<b>Username:</b> $logged[username]"); echo (" <b>||</b> <b>E-mail:</b> $logged[email]"); echo (" <b>||</b>"); ?> <?php // working one include('config.php'); $get = mysql_query("SELECT * from pmessages where touser = '$logged[username]' order by id desc");$nummessages = mysql_num_rows($get); if ($nummessages == 0) { echo ("You have 0 messages!"); } else { echo ("You Have A Message"); } // working one ?> But is that keeps saying there is a message untill you delete all your messages in your inbox... Is there any way i can stop that? Please Help Thanks Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 25, 2009 Share Posted April 25, 2009 Not unless you have some sort of indicator in the pmessages table that gets set when a person reads a message. Quote Link to comment Share on other sites More sharing options...
dean7 Posted April 25, 2009 Author Share Posted April 25, 2009 im not sure if i have... but this is messages.php witch has the inbox in with it: <?php $subject = htmlspecialchars(addslashes("$_POST[subject]")); $message = htmlspecialchars(addslashes("$_POST[message]")); $to = htmlspecialchars(addslashes("$_POST[to]")); //the above lines remove html and add \ before all " $send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` , `touser` , `from` , `unread` , `date` ) VALUES ('$subject', '$message', '$to', '$logged[username]', 'unread', NOW())"); echo (" <a href='messages.php?page=inbox'>Go Back</a><br><br> Your message has been sent."); } break; case 'delete': if (!$_GET[msgid]) { echo (" <a href='messages.php?page=inbox'>Go Back</a><br><br> Sorry, but this is an invalid message. "); } else { $getmsg = mysql_query("SELECT * from pmessages where id = '$_GET[msgid]'"); $msg = mysql_fetch_array($getmsg); //hmm..someones trying to delete someone elses messages! This keeps them from doing it if ($msg[touser] != $logged[username]) { echo (" <a href='messages.php?page=inbox'>Go Back</a><br><br> This message was not sent to you! "); } else { $delete = mysql_query("delete from pmessages where id = '$_GET[msgid]'"); echo (" <a href='messages.php?page=inbox'>Go Back</a><br><br> Message Deleted! "); } } break; case 'deleteall': $delete = mysql_query("delete from pmessages where touser = '$logged[username]'"); echo (" <a href='messages.php?page=inbox'>Go Back</a><br><br> All Message Deleted! "); break; case 'inbox': $get = mysql_query("SELECT * from pmessages where touser = '$logged[username]' order by id desc"); echo(" <a href='messages.php?page=write'>Create New Message</a><br><br> <a href='messages.php?page=deleteall'>Delete All Messages</a><br><br> <table border=\"0\" width=\"100%\" cellspacing=\"0\"> <tr> <td align=\"center\" style=\"border-bottom:#000000 solid 1px;\">Subject</td> <td align=\"center\" width=\"125\" style=\"border-bottom:#000000 solid 1px;\">From</td> <td align=\"center\" width=\"97\" style=\"border-bottom:#000000 solid 1px;\">Date</td> <td width=\"25\" style=\"border-bottom:#000000 solid 1px;\">Delete</td> </tr> </table> "); $nummessages = mysql_num_rows($get); if ($nummessages == 0) { echo ("You have 0 messages!"); } else { echo("<table border=\"0\" width=\"100%\" cellspacing=\"1\">"); while ($messages = mysql_fetch_array($get)) { //the above lines gets all the messages sent to you, and displays them with the newest ones on top echo (" <tr> <td><a href=\"messages.php?page=view&msgid=$messages[id]\">"); if ($messages[reply] == yes) { echo ("Reply to: "); } echo ("$messages[title]</a></td> <td width=\"125\">$messages[from]</td> <td width=\"97\">$messages[date]</td> <td width=\"25\"><a href=\"messages.php?page=delete&msgid=$messages[id]\">Delete</a></td> </tr>"); } echo ("</table>"); } ?> Thats only some of it because all of the code is rather long.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.