Pms wont open

Posted on Tuesday 29th July 2008 at 04:28 PM
VicVance
VicVance's Avatar
I am using rmb private message system and it all works but it wont let me view my message.there is no error it jusr refrches the page back to pm's. This is the code.

PHP Code
  1. <?php
  2. session_start(); //Start session
  3. include("config.php"); //Include config file
  4. if(!$logged[id]){ //Check if user is logged in
  5. echo "<b>Error</b>: You Are Not Logged In!"; //Not logged in
  6. }else{ //Their loggedin
  7. switch($_GET[act]){ //make some links ?page=case
  8. default: //set up the default page upon going to pms.php
  9. $msgs = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "' ORDER BY `pid` ASC") or die(mysql_error()); //get all the messages to the loged in user
  10. echo "<a href="?page=pms&act=compose">Compose Message</a>
  11. <a href="?page=pms&act=delall">Delete All Messages</a>
  12.  
  13. <table width="350" cellpadding="0" cellspacing="3">
  14. <tr>
  15. <td align="center" valign="middle" width="100">
  16. <b>Subject</b>
  17. </td>
  18. <td align="center" valign="middle" width="50">
  19. <b>From</b>
  20. </td>
  21. <td align="center" valign="middle" width="50">
  22. <b>Date Sent</b>
  23. </td>
  24. <td align="center" valign="middle" width="50">
  25. <b>Status</b>
  26. </td>
  27. <td align="center" valign="middle" width="100">
  28. <b>Delete Message</b>
  29. </td>
  30. </tr>"; //echo the start5 table and create msg link/delete all links!
  31. if(mysql_num_rows($msgs) == 0){ //check if there are messages or not
  32. echo "<tr><td width="300" colspan="3" align="center" valign="middle">You Have No New Messages!</td></tr>"; //no new messages
  33. }else{ //or if there are messages
  34. while($r = mysql_fetch_array($msgs)){ //repeat for all the messages
  35. echo "<tr><td align="center" valign="middle" width="100">
  36. <a href="pms.php?page=view&id=$r[pid]">$r[subject]</a></td>
  37. <td align="center" valign="middle" width="50">
  38. <a href="members.php?user=$r[from]">$r[from]</a>
  39. </td>
  40. <td align="center" valign="middle" width="50">
  41. $r[date]
  42. </td>
  43. <td align="center" valign="middle" width="50">
  44. $r[status]
  45. </td>
  46. <td align="center" valign="middle" width="100">
  47. <a href="pms.php?page=delete&id=$r[pid]">Delete</a>
  48. </td>
  49. </tr>"; //echo the messages
  50. } //end while
  51. } //end message amount check
  52. echo "</table>"; //end table
  53. break; //end the default page
  54. case 'view': //define the view page
  55. $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe
  56. if(!$id){ //if there is no ID to select
  57. echo "<a href="pms.php">Go Back</a>No ID Selected!"; //echo the error
  58. }else{ //or if there is....
  59. $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "';"); //get the message's info
  60. $msg = mysql_fetch_array($select); //select all data
  61. if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message
  62. echo "<a href="pms.php">Go Back</a>This Message Was Not Sent To You"; //if not
  63. }else{ //maybe...
  64. if(!$_POST[reply]) { //if the reply was not submitted
  65. $mark = mysql_query("UPDATE `privates` SET `status` = 'Read' WHERE `pid` = '" . $id . "'") or die(mysql_error()); //mark it as Read
  66. $message = nl2br(stripslashes($msg[content])); //make new lines to and strip the slashes
  67. $subject = stripslashes($msg[subject]); //strip the slashes
  68. echo "<a href="pms.php">Go Back</a>
  69. <form method="post">
  70. <dl style="margin: 0px;">
  71. <dt><b>Subject</b>: $subject</dt>
  72. <dt><b>From</b>: $msg[from]</dt>
  73. <dt>$message</dt>
  74. <dt><textarea rows="6" cols="45" name="msg"></textarea>
  75. <input type="submit" name="reply" value="Reply"></dt>
  76. </dl>
  77. </form>"; //echo the message and reply box.
  78. }else{ //if the form was submitted
  79. $to = $msg[from]; //get who it is to
  80. $from = $logged[username]; //who its from
  81. $subject = "RE: " . $msg[subject]; //new subject
  82. $msg = addslashes($_POST[msg]); //the content
  83. $date = date("F j, Y, g:i a"); //the date sent
  84. $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
  85. echo "Message Sent!"; //the message was sent
  86. } //end reply check
  87. } //end check posession
  88. } //end id check
  89. break;
  90. case 'compose': //create a new message
  91. if(!$_POST[send]){ //if the form was not submitted
  92. echo "<a href="?page=pms">Go Back</a>
  93. <form method="post" action="">
  94. <b>To User</b>:<Br />"; //echo some of the form and whatnot
  95. if(isset($_GET[user])){ //check if there is a user in the address bar
  96. echo "<input type="text" name="to" value="$_GET[user]" size="15">"; //if there is
  97. }else{ //or not..
  98. echo "<input type="text" name="to" size="15">"; //echo the input box without the value of the user!
  99. } //end user check in address bar
  100. echo "<b>Subject</b>:
  101. <input type="text" name="title" value="Unitiled Message" size="15">
  102. <b>Content</b>:
  103. <textarea name="message" rows="6" cols="45"></textarea>
  104. <input type="submit" name="send" value="Send Message">
  105. </form>"; //echo the rest of the form
  106. }else{ //or if it was....
  107. $to = stripslashes(htmlspecialchars(strip_tags($_POST[to]))); //who its to
  108. $from = $logged[username]; //who its from
  109. $date = date("F j, Y, g:i a"); //the date sent
  110. $msg = addslashes($_POST[message]); //the message variable
  111. $subject = addslashes($_POST[title]); //the subject
  112. $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
  113. echo "Message Sent!";
  114. } //end sent check
  115. break; //end make new msg
  116. case 'delall': //delete all page
  117. $get = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //get the private messages
  118. if(mysql_num_rows($get) == "0"){
  119. echo "You Have No Messages To Delete!";
  120. }else{
  121. $delete = mysql_query("DELETE FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //delete tehm
  122. if($delete) { //check if theres a mySQL error
  123. echo "Messages Deleted"; //success
  124. }else{ //or not
  125. echo "mySQL Error Encountered!";
  126. } //end error check
  127. } //end msg check
  128. break; //end page
  129. case 'delete': //start the delete page!
  130. $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe
  131. if(!$id){ //if there is no ID to select
  132. echo "<a href="?page=pms">Go Back</a>No ID Selected!"; //echo the error
  133. }else{ //or if there is....
  134. $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "'"); //get the message's info
  135. $msg = mysql_fetch_array($select); //select all data
  136. if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message
  137. echo "<a href="?page=pms">Go Back</a>This Message Was Not Sent To You"; //if not
  138. }else{ //maybe...
  139. $do = mysql_query("DELETE FROM `privates` WHERE `pid` = '" . $id . "'") or die(mysql_error());
  140. echo "<a href="?page=pms">Go Back</a><Br />Messages Deleted!";
  141. } //end check possession
  142. } //end id check
  143. break; //end the delete page!
  144. } //end switch/get
  145. } //end login check
  146. ?>


and I also wanted to know how to add a link that would show if i got a new pm.


thanks
Login or register to respond to this forum topic.